Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sqs-consumer-pool

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sqs-consumer-pool

Manager for consumer pools for AWS SQS

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
increased by6.56%
Maintainers
1
Weekly downloads
 
Created
Source

sqs-consumer-pool

Consumers for AWS SQS - Promise based

Description

Create a pool of consumers to consume many messages/jobs at once and increase concurrency. You can scale the number of consumers up and down easily. This package was created after reviewing the inner workings of sqs-consumer.

Getting Started

You will need the following environment variables set:

AWS_ACCESS_KEY_ID=<your-access-key-id>
AWS_SECRET_ACCESS_KEY=<your-access-key>

You can accomplish this by using dotenv if you like. Use their documentation for reference.

Import the ConsumerManager into your project. First params is the pool size and the second is the options object.

const {ConsumerManager, Consumer} =  require('aws-sqs-consumer')

const manager = new ConsumerManager(2, {
    queueUrl: 'https://www.queueurl.com',
    handleMessage: async (message) => {
        
        return yourCustomFunction(message)
    }
})

Possible Options

{
  batchSize: 10,
  attributeNames: [],
  messageAttributeNames: [],
  visibilityTimeout: 120,
  waitTimeSeconds: 20,
  authenticationErrorTimeout: 10000,
  queueUrl: 'http://that.queueurl.io',
  sqs: new AWS.SQS() // prebuilt sqs object,
  log: winston // default is console
  region: 'us-east-1', // AWS region
  handleMessage: (message) => {
    
    // add your custom logic here. Remember, this is promise based!
  },
  events: {
    messageReceived: (message) => {},
    error: (message, error) => {},
    processingError: (message, error) => {},
    messageProcessed: (message) => {},
    empty: () => {},
    stopped: () => {},
  }
}

The events section contains possible event functions you can pass in for custom functionality.

Each consumer will grab 10 messages at a time if you leave the default, which is the max AWS SQS allows. This means for n number of consumers, to get the concurrent number of messages being processed, you would just do n * 10.

Default polling is set to short polling. If you pass waitTimeSeconds, this will cause long polling.

Keywords

FAQs

Package last updated on 04 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc