Created
July 3, 2016 11:54
-
-
Save liorkesos/5d4ba820957c983f95c582e305b4f43d to your computer and use it in GitHub Desktop.
Using a queue in node-busmq consumer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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