2.1.0 • Published 5 years ago

sqs-queue-consumer v2.1.0

Weekly downloads
5
License
MIT
Repository
gitlab
Last release
5 years ago

SQS Queue Consumer

A handy consumer for AWS SQS queues.

Usage

import SqsQueueConsumer from 'sqs-queue-consumer';

const params = {
  intervalSeconds: 15,
  aws: {
    region: "eu-central-1",
    // Can contain any AWS config setting
  },
  sqs: {
    queueUrl: 'https://some.aws.queue.url.com/',
  }
};
const listener = SqsQueueConsumer(params);

listener.on("message", (message, next) => {

  // Do something with your message object.
  console.log(message.body); // an object if the message body is JSON, a string otherwise
  console.log(message.rawMessage); // the raw message as received from AWS

  message.delay(5); // delay the visibility of the message for 5 seconds
  message.remove(); // remove the message from the queue

  next();
});

listener.on("error", (error) => {
  // Do something with your error.
  // No need to call next().
});

listener.start();

AWS Credentials

There is no way to pass your AWS credentials directly to the SQS Queue Consumer. Instead, put them in your environment variables.

AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-access-key
2.1.0

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago