// send.js
amqp.connect('amqp://localhost', function(err, conn) {
conn_ = conn;
conn.createChannel(function(err, ch) {
ch_ = ch;
var q = 's1';
ch.assertQueue(q, {durable: false});
ch.sendToQueue(q, new Buffer('Hello World! '+ +new Date()));
});
});
// read.js
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch) {
var q = config.rabbitmq.queue_name;
ch.assertQueue(q, {durable: false});
ch.consume(q, (msg) => {
console.log(msg.content.toString());
});
});
});