Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var amqp = require('amqplib');
- var connection_string = 'amqp://cgaiyapd:CVE3r1gZXafXtZMqSNKz_V3SUkQB0GTj@bear.rmq.cloudamqp.com/cgaiyapd';
- amqp.connect(connection_string)
- .then(function(connection) {
- return connection.createChannel()
- .then(function(channel) {
- var exchange = 'greetings';
- var ok = channel.assertExchange(exchange, 'fanout', {durable: false})
- var message = process.argv.slice(2).join(' ') || 'info: Greetings the message communication!';
- return ok
- .then(function() {
- channel.publish(exchange, '', Buffer.from(message));
- console.log(" [x] Sent '%s'", message);
- return channel.close();
- });
- })
- .finally(function() { connection.close(); });
- })
- .catch(console.warn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement