UNPKG

mqlight-dev

Version:
23 lines (18 loc) 625 B
var mqlight = require('mqlight-dev'); var client = mqlight.createClient({service: 'amqp://localhost:5672'}); client.on('started', function() { client.subscribe('news/technology', function(err, pattern) { if (err) { console.error('Problem with subscribe request: ', err.toString()); } else { console.log('Subscribed to pattern: ', pattern); console.log('Sending message : Hello World!'); client.send('news/technology', 'Hello World!'); } }); client.on('message', function(data) { console.log('Got message: ', data); console.log('Exiting.'); process.exit(0); }); });