sqs-producer
![Test Coverage](https://codeclimate.com/github/BBC/sqs-producer/badges/coverage.svg)
Enqueues messages onto a given SQS queue
Installation
npm install sqs-producer --save
Usage
var Producer = require('sqs-producer');
var producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1'
});
var producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1'
accessKeyId: 'yourAccessKey',
secretAccessKey: 'yourSecret'
});
producer.send(['msg1', 'msg2'], function(err) {
if (err) console.log(err);
});
producer.queueSize(function (err, size) {
if (err) console.log(err);
console.log('There are', size, 'messages on the queue.');
});
producer.send([{
id: 'id1',
body: 'Hello world'
}], function(err) {
if (err) console.log(err);
});
producer.send([
{
id: 'id1',
body: 'Hello world with two string attributes: attr1 and attr2',
messageAttributes: {
attr1: { DataType: 'String', StringValue: 'stringValue' },
attr2: { DataType: 'Binary', BinaryValue: new Buffer('binaryValue') }
}
},
{
id: 'id2',
body: 'Hello world delayed by 5 seconds',
delaySeconds: 5
}
], function(err) {
if (err) console.log(err);
});
producer.send({
body: 'Hello world from our FIFO queue!',
groupId: 'group1234',
deduplicationId: 'abcdef123456'
}, function(err) {
if (err) console.log(err);
});
Test
npm test
Coverage
For coverage report, run the command:
npm run coverage
JSLint
To check for problems using JSLint
npm run lint