blob: c25cfbcc2bb5582ab071adb2e9b555c8e78fab4f [file] [log] [blame]
#!/usr/bin/env node
// Post a new task to the work queue
var amqp = require('amqplib');
amqp.connect('amqp://localhost').then(function(conn) {
return conn.createChannel().then(function(ch) {
var q = 'task_queue';
var ok = ch.assertQueue(q, {durable: true});
return ok.then(function() {
var msg = process.argv.slice(2).join(' ') || "Hello World!";
ch.sendToQueue(q, Buffer.from(msg), {deliveryMode: true});
console.log(" [x] Sent '%s'", msg);
return ch.close();
});
}).finally(function() { conn.close(); });
}).catch(console.warn);