SHARE
TWEET

Untitled

a guest Mar 24th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var amqp = require('amqplib');
  2.  
  3. var connection_string = 'amqp://cgaiyapd:CVE3r1gZXafXtZMqSNKz_V3SUkQB0GTj@bear.rmq.cloudamqp.com/cgaiyapd';
  4. amqp.connect(connection_string)
  5.     .then(function(connection) {
  6.       return connection.createChannel()
  7.             .then(function(channel) {
  8.                 var exchange = 'greetings';
  9.                 var ok = channel.assertExchange(exchange, 'fanout', {durable: false})
  10.  
  11.                 var message = process.argv.slice(2).join(' ') || 'info: Greetings the message communication!';
  12.  
  13.                 return ok
  14.                     .then(function() {
  15.                       channel.publish(exchange, '', Buffer.from(message));
  16.                       console.log(" [x] Sent '%s'", message);
  17.                       return channel.close();
  18.                     });
  19.               })
  20.             .finally(function() { connection.close(); });
  21.     })
  22.     .catch(console.warn);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top