Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/homuchen/aws-sqs-service

AWS Simple Queue Service(SQS) supporting long-polling long-lived process worker consuming jobs in queue
https://github.com/homuchen/aws-sqs-service

sqs worker

Last synced: about 1 month ago
JSON representation

AWS Simple Queue Service(SQS) supporting long-polling long-lived process worker consuming jobs in queue

Awesome Lists containing this project

README

        

# aws-sqs-service
AWS Simple Queue Service(SQS)

## Requirement
Enviroment variables - IAM credentials
```bash
export AWS_ACCESS_KEY_ID=your-id
export AWS_SECRET_ACCESS_KEY=your-secret
```

## Install
```bash
npm i -S sqs-service
```

## Usage
### Config
```js
const QueueService = require('aws-sqs-service');
const sqs = new QueueService(options);
```
#### options
* region -- required
* batchSize -- The maximum number of messages to return. valid value 1 to 10. Default 1.
* apiVersion

### Send Message to Queue
```js
sqs.sendMessage(url, payload) //url -> queueUrl, payload -> JSON object
```

### Consume from Queue
```js
sqs.consume(url, function(data, done) => {
//doSomethingWith(data)
//done()

//doSomethingAsyncWith(data)
// .then(_ => done())
})
```