1.0.11 • Published 5 years ago

rabbitmq-amqp v1.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Install

$ npm install rabbitmq-amqp

Usage

First of all, define Exchange, Queue and Binding between them in your RabbitMQ with 'durable' option in true. Then create an instance.

Examples

Create instance

//URL format: amqp://username:password@hostname-or-IP
const rabbit = new RabbitMQ(url)

Consume from queue

rabbit.consume('queue-name', callback , options) Options defaults: { noAck: true, priority: null } http://www.squaremobius.net/amqp.node/channel_api.html#channel_consume

rabbit.on('connected', () => {
    rabbit.consume('queue-name', msg => {
        console.log('New message received: ', msg)
    })
})

Publish in exchange

rabbit.publish('exchange-name', message , options)) Options defaults: { topic: '', expirations: null, priority: null, persistent: false } http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish

rabbit.publish('exchange-name', 'Hello world!')

Events

On connect

rabbit.on('connect', () => { console.log('Connected to RabbutMQ!') })

On disconnect

rabbit.on('disconnect', (reason) => { console.log(`Disconnected to RabbutMQ!. Reason: ${reason}`) })

amqplib Documentation

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago