Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement