🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@gasbuddy/configured-sqs-client

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gasbuddy/configured-sqs-client

A configuration driven SQS client

latest
npmnpm
Version
1.9.0
Version published
Maintainers
1
Created
Source

configured-sqs-client

Node CI

A small wrapper around the AWS SQS sdk and sqs-consumer to allow configuration from confit. Unlike configured-rabbitmq-client, most queue configuration for SQS is done OUTSIDE of the infrastructure here (assumedly will be terraform or similar). So this module focuses on publishing and consuming messages, but with as similar an configuration specification as possible.

Usage

See the test directory for sample usage. To send a message, you must configure a logical queue, something like:

{
  region: 'us-east-1',
  queues: {
    basic: 'basic_queue'
  }
}

Now, you can publish to this queue using:

  configuredSqsClient.publish(req, 'basic', { some: 'message' });

To receive this message, you would subscribe:

  sqs.subscribe(context, 'basic', async (req, message, envelope) => {
    // Do stuff, await stuff, throw errors, whatever
  });

If your handler throws an error, the redrive policy of the queue takes over. However, if your handler marks that error with a property "deadLetter" that is either true or the name of another queue, the failed attempt will be published on the target queue (either the deadLetter property of the queue that was configured in your configured-sqs-client config, or the queue specified in the deadLetter error property).

Compression

Max message size allowed through SQS is 256kb. You can compress/deflate your message if you think it could go over that limit.

  configuredSqsClient.publish(req, 'basic', { some: 'message' }, { compression: true });

The deflated message will automatically be inflated before delivering to a consumer

Testing this package

docker run -p 9324:9324 gasbuddy/sqs-mock:latest
npm run test

Keywords

sqs

FAQs

Package last updated on 26 May 2021

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