sqsqs
TypeScript icon, indicating that this package has built-in type declarations

0.2.8 • Public • Published

sqsqs

SQSQS(Simple Quick SQS wrapper)

Usage

import Queue from 'sqsqs';
// const Queue = require("sqsqs").default;
 
const awsConfig = {
  apiVersion: '2012-01-01',
  region: 'ap-northeast-2',
};
const queue = new Queue({ QueueUrl: string, }, awsConfig);
 
const data1 = "data1"
const data2 = "data2"
 
/* Send any number of string messages */
/* Warning: the order of messages are not kept in the batch list! */
await queue.send([data1, data2])
 
/* Receive specific number of string messages */
/* it might wait until messages count reach that number or there are no remain messages in SQS queue */
let queueSize = 50
let received = await queue.receive(queueSize)
 
/* ***
received = [{
  Body: "data1",
  ReceiptHandleId: ...,
  Id: ...
},{
  Body: "data2",
  ReceiptHandleId: ...,
  Id: ...
}]
*** */
 
/* parallel receive */
/* the final message count could exceed the queueSize */
let concurrency = 10
let received = await queue.receive(queueSize, concurrency)
 
 
/* Delete Messages */
await queue.delete(received);
 
/* Heartbeat Messages */
await queue.heartbeat(received);
 

Readme

Keywords

none

Package Sidebar

Install

npm i sqsqs

Weekly Downloads

1

Version

0.2.8

License

none

Unpacked Size

26.9 kB

Total Files

10

Last publish

Collaborators

  • song9446