Skip to content

Repository files navigation

SQS-LOOP

SQS polling lib to ease the creation of consumers that run forever.

npm install --save sqs-loop
constsqsLoop=require('sqs-loop');sqsLoop.aws.config.update({accessKeyId: process.env.AWS_ACCESS_KEY_ID,secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,region: 'us-east-1'});constparams={QueueName: 'awesome-queue',// auto create and resolves queue urlVisibilityTimeout: 5,MaxNumberOfMessages: 5,WaitTimeSeconds: 20};// Callback will be called once per message in parallel by MaxNumberOfMessagessqsLoop.loop(params,message=>{constbody=JSON.parse(message.Body);/* * work with our message */// If we want to loop no further// return sqsLoop.stop();// If we want to keep the messsage in SQS// return sqsLoop.keep();});

Return values

  • sqsLoop.stop(): stops the loop and resolves the promise
  • sqsLoop.keep(): avoid removal of the message from SQS queue
  • promise rejections: keep the message on the queue.
  • promise resolves or normal returns: removes the message from SQS queue

About

SQS polling lib to ease the creation of consumers that run forever.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages