polish_rabbit
v1.0.2
Published
Lib for rabbitmq queues implementation in Node Js
Downloads
2
Readme
Polish Rabbit
Description
Simple package to handle with rabbitmq connection and channels with amqplib abstraction.
Features
Connect to host Close connection Create channel Send messages to queues Consume messages from queues Delete queues Purge queues
Runnig Rabbitmq instance
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.9-management
Consuming messages
Client.dequeue(options)
import Channel from './lib/channel.js'
const cli = new Channel({ uri: 'amqp://guest:guest@localhost:5672', queue: 'your_queue' })
async function get() {
await cli.createChannel()
for await (const message of await cli.dequeue()) {
console.log(message)
}
}
get()
Publishing messages:
import Channel from './lib/channel.js'
const cli = new Channel({ uri: 'amqp://guest:guest@localhost:5672', queue: 'your_queue' })
async function send() {
await cli.createChannel()
cli.enqueue('your_string_message')
}
send()