var amqp = require('amqp'); var connection = amqp.createConnection({ host: 'localhost' }); // Wait for connection to become established. connection.on('ready', function () { // Use the default 'amq.topic' exchange connection.queue('worker-queue', { durable: true}, function (q) { // Route key identical to the MQTT topic q.bind('activities'); // Receive messages q.subscribe(function (message, headers, deliveryInfo, messageObject) { // Print messages to stdout console.log('Node AMQP('+process.pid+'): received topic "'+ deliveryInfo.routingKey+ '", message: "'+ message.data.toString ()+'"'); }); }); });
|