Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const amqp = require('amqplib');
- amqp.connect({
- protocol: 'amqp',
- hostname: 'amqp.notifai.io',
- port: 5672,
- username: AMQP_USER,
- password: AMQP_PASSWORD,
- locale: 'en_US',
- frameMax: 0,
- heartbeat: 30,
- vhost: 'arbnco'
- })
- .then(connection => {
- console.log('connected')
- return connection.createChannel()
- })
- .then(channel => {
- console.log('channel created')
- const queue = 'any-queue-really'
- channel.prefetch(1)
- .then(() => channel.assertQueue(queue))
- .then(() => channel.bindQueue(queue, 'events', 'controller.updated.v1'))
- .then(() => {
- channel.consume(queue, message => console.log(message))
- console.log(`Starts listening to '${queue}'`)
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement