To get an instance of the SQS wrapper:
const sqs = require('@sparkpost/aws').SQS({
account: 'abc123',
queuePrefix: 'sqs-',
queueSuffix: '-prd',
defaultVisibilityTimeout: 301
});account is required and is the AWS account ID.
queuePrefix and queueSuffix are optional and default to the empty string. They are used in constructing the SQS queue URL.
defaultVisibilityTimeout is optional and defaults to 300s. It sets the VisibilityTimeout value when retrieving messgaes from a queue.
Returns the queue url used by this instance.
const url = sqs.getQueueUrl(queueName);Purges the queue of messages.
sqs.purge(queueName)
.then(() => console.log('purged!'))
.catch((err) => console.log(err)));Removes a batch of messages from the queue
sqs.remove({ queueName, entries })
.then(() => console.log('removed!'))
.catch((err) => console.log(err)));Retrieves a batch of messages from the queue.
max defaults to 10, messageAttributeNames defaults to an empty array.
sqs.retrieve({ queueName, max, messageAttributeNames, visibilityTimeout })
.then(() => console.log('retrieved!'))
.catch((err) => console.log(err)));Sends a message to the queue.
sqs.send({ queueName, payload, attrs })
.then(() => console.log('sent!'))
.catch((err) => console.log(err)));Changes the visibility timeout of a handle.
sqs.setVizTimeout({ queueName, handle, timeout })
.then(() => console.log('setVizTimeout-ed!'))
.catch((err) => console.log(err)));