Package Exports
- @sagacify/sqs-move
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sagacify/sqs-move) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SQS-Move
Moving SQS messages with ease.
Motivation
Most of the time when you use an SQS queue you also define a deadletter queue.
This is a great idea, so when your service has a bug you can correct it and
then repush all the messages in your deadletter queue to the orignal queue.
Unfortunatly the AWS interface doeesn't provide an action to move your message.
You have to do it programmatically, this is where sqs-move
will help you.
Of course, you can use it to move messages from any queue to any other queue.
Installation
$ npm install @sagacify/sqs-move
Usage
sqs-move is a simple function.
Signature
async function(sqsInstance, fromQueueUrl, toQueueUrl, batchSize = 1)
Notes:
- batchSize maximum is 10
- sqsInstance is expected to be an AWS.SQS instance
Example
const AWS = require('aws-sdk');
const sqsMove = require('@sagacify/sqs-move');
const sqsInstance = new AWS.SQS({
accessKeyId: 'some-aws-id',
secretAccessKey: 'some-aws-secret',
region: 'eu-west-1'
});
await sqsMove(
sqsInstance,
'https://sqs.eu-west-1.amazonaws.com/123456789012/some-dead-letter-queue',
'https://sqs.eu-west-1.amazonaws.com/123456789012/some-original-queue',
10
);
console.log('All messages are back in original queue !');