Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gas-buddy/configured-sqs-client
A configuration driven Node.js SQS client
https://github.com/gas-buddy/configured-sqs-client
Last synced: about 2 months ago
JSON representation
A configuration driven Node.js SQS client
- Host: GitHub
- URL: https://github.com/gas-buddy/configured-sqs-client
- Owner: gas-buddy
- Created: 2020-02-02T05:32:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-22T16:17:03.000Z (over 3 years ago)
- Last Synced: 2024-04-15T00:45:49.472Z (10 months ago)
- Language: JavaScript
- Size: 1.5 MB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
configured-sqs-client
==========================![Node CI](https://github.com/gas-buddy/configured-sqs-client/workflows/Node%20CI/badge.svg)
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 consumerTesting this package
=====
```
docker run -p 9324:9324 gasbuddy/sqs-mock:latest
npm run test
```