https://github.com/zackify/amqp-modern
Publish json messages and subscribe to AMQP servers using async / await
https://github.com/zackify/amqp-modern
Last synced: 11 months ago
JSON representation
Publish json messages and subscribe to AMQP servers using async / await
- Host: GitHub
- URL: https://github.com/zackify/amqp-modern
- Owner: zackify
- Created: 2018-07-31T18:11:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T08:11:30.000Z (over 3 years ago)
- Last Synced: 2025-02-14T04:49:49.979Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 106 KB
- Stars: 0
- Watchers: 9
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## AMQP Modern
A small `amqplib` wrapper for nodejs that simplifies interactions with queue systems.
- Consuming a channel
- Async / Await based
- Publishing to a channel
- Passing off JS objects, so you don't have to
- It handles rejections and acknowledgments automatically
## Install
```
npm install amqp-modern
```
## Usage
```js
import amqp from 'amqp-modern';
let client = amqp('amqp://connection string here');
//optional config
client.config({
//catch and log any time a queue has an error
onError: error => console.log(error),
//wait 10 seconds after each failure, useful to not reject and retry instantly, probably looping really fast
rejectionDelay: 10000,
});
//consume a channel
client.consume({
channel: 'message',
process: async message => {
await sendAnEmail(message.description);
//if this promise rejects, the queue will retry
},
});
//somewhere in your app, publish to a channel
client.publish('message', { description: 'hello!' });
```