Skip to content

Instantly share code, notes, and snippets.

@liorkesos
Created July 3, 2016 11:54
Show Gist options
  • Save liorkesos/5d4ba820957c983f95c582e305b4f43d to your computer and use it in GitHub Desktop.
Save liorkesos/5d4ba820957c983f95c582e305b4f43d to your computer and use it in GitHub Desktop.
Using a queue in node-busmq consumer
var Bus = require('busmq');
var bus = Bus.create({redis: ['redis://127.0.0.1:6379']});
bus.on('online', function() {
var q = bus.queue('foo');
q.on('attached', function() {
console.log('attached to queue. messages will soon start flowing in...');
});
q.on('message', function(message, id) {
if (message === 'my name if foo') {
q.detach();
}
});
q.attach();
q.consume(); // the 'message' event will be fired when a message is retrieved
});
bus.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment