Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
sqs-producer
Advanced tools
Readme
Enqueues messages onto a given SQS queue.
To install this package, enter the following command into your terminal (or the variant of whatever package manager you are using):
npm install sqs-producer
Note This library assumes you are using AWS SDK v3. If you are using v2, please install v2.2.0:
npm install sqs-producer@2.2.0 --save-dev
We will only support Node versions that are actively or security supported by the Node team. If you are still using an Node 14, please use a version of this library before the v3.2.1 release, if you are using Node 16, please use a version before the v3.3.0 release.
Visit https://bbc.github.io/sqs-producer/ for the full API documentation.
import { Producer } from 'sqs-producer';
import { SQSClient } from '@aws-sdk/client-sqs';
// create simple producer
const producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1'
});
// send messages to the queue
await producer.send(['msg1', 'msg2']);
// get the current size of the queue
const size = await producer.queueSize();
console.log(`There are ${size} messages on the queue.`);
// send a message to the queue with a specific ID (by default the body is used as the ID)
await producer.send([
{
id: 'id1',
body: 'Hello world'
}
]);
// send a message to the queue with
// - delaySeconds (must be an number contained within 0 and 900)
// - messageAttributes
await producer.send([
{
id: 'id1',
body: 'Hello world with two string attributes: attr1 and attr2',
messageAttributes: {
attr1: { DataType: 'String', StringValue: 'stringValue' },
attr2: { DataType: 'Binary', BinaryValue: new Buffer('binaryValue') }
}
},
{
id: 'id2',
body: 'Hello world delayed by 5 seconds',
delaySeconds: 5
}
]);
// send a message to a FIFO queue
//
// note that AWS FIFO queues require two additional params:
// - groupId (string)
// - deduplicationId (string)
//
// deduplicationId can be excluded if content-based deduplication is enabled
//
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queue-recommendations.html
await producer.send({
id: 'testId',
body: 'Hello world from our FIFO queue!',
groupId: 'group1234',
deduplicationId: 'abcdef123456' // typically a hash of the message body
});
By default the consumer will look for AWS credentials in the places specified by the AWS SDK. The simplest option is to export your credentials as environment variables:
export AWS_SECRET_ACCESS_KEY=...
export AWS_ACCESS_KEY_ID=...
If you need to specify your credentials manually, you can use a pre-configured instance of the SQS Client client.
import { Producer } from 'sqs-producer';
import { SQSClient } from '@aws-sdk/client-sqs';
// create simple producer
const producer = Producer.create({
queueUrl: 'https://sqs.eu-west-1.amazonaws.com/account-id/queue-name',
region: 'eu-west-1',
sqs: new SQSClient({
region: 'my-region',
credentials: {
accessKeyId: 'yourAccessKey',
secretAccessKey: 'yourSecret'
}
})
});
// send messages to the queue
await producer.send(['msg1', 'msg2']);
npm test
For coverage report, run the command:
npm run coverage
To check for problems using ESLint
npm run lint
We welcome and appreciate contributions for anyone who would like to take the time to fix a bug or implement a new feature.
But before you get started, please read the contributing guidelines and code of conduct.
SQS Producer is distributed under the Apache License, Version 2.0, see LICENSE for more information.
FAQs
Enqueues messages onto a given SQS queue
The npm package sqs-producer receives a total of 88,598 weekly downloads. As such, sqs-producer popularity was classified as popular.
We found that sqs-producer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.