-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1send.js
More file actions
33 lines (24 loc) · 681 Bytes
/
1send.js
File metadata and controls
33 lines (24 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
var amqp = require('amqplib/callback_api'); //get the library
//connect to RabbitMQ server
amqp.connect('amqp://localhost', function(error0, connection) {
if(error0){
throw error0;
}
connection.createChannel(function(error1, channel) {
if(error1){
throw error1;
}
var queue = 'hello';
var msg = 'Hello world';
channel.assertQueue(queue, {
durable: false
});
channel.sendToQueue(queue, Buffer.from(msg));
console.log(" [x] Sent %s", msg);
});
setTimeout(function() {
connection.close();
process.exit(0);
}, 500);
});