Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const amqp = require('amqplib');
  2.  
  3. amqp.connect({
  4.     protocol: 'amqp',
  5.     hostname: 'amqp.notifai.io',
  6.     port: 5672,
  7.     username: AMQP_USER,
  8.     password: AMQP_PASSWORD,
  9.     locale: 'en_US',
  10.     frameMax: 0,
  11.     heartbeat: 30,
  12.     vhost: 'arbnco'
  13.   })
  14.   .then(connection => {
  15.     console.log('connected')
  16.  
  17.     return connection.createChannel()
  18.   })
  19.   .then(channel => {
  20.     console.log('channel created')
  21.  
  22.     const queue = 'any-queue-really'
  23.  
  24.     channel.prefetch(1)
  25.       .then(() => channel.assertQueue(queue))
  26.       .then(() => channel.bindQueue(queue, 'events', 'controller.updated.v1'))
  27.       .then(() => {
  28.         channel.consume(queue, message => console.log(message))
  29.         console.log(`Starts listening to '${queue}'`)
  30.       })
  31.   })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement