Skip to content

Instantly share code, notes, and snippets.

@cliftonc
Created October 1, 2014 18:51
Show Gist options
  • Save cliftonc/daf8df18f1abf756a86c to your computer and use it in GitHub Desktop.
Save cliftonc/daf8df18f1abf756a86c to your computer and use it in GitHub Desktop.
Example rabbitmq stuff
var queueService = require('module-tsl-rabbit/Queue');
var exchangeService = require('module-tsl-rabbit/Exchange');
var resourceHandler = {
onMessage: function (data, message, ackFn, nackFn) {
console.dir(data); // expect {hello:"world"}
ackFn();
}
}
async.series([
exchangeService.connect('resourceTopic'),
queueService.listen('resourceQueue', resourceHandler),
],function(err) {
exchangeService.exchanges.resourceTopic.publish({hello:"world"});
});
/* ... elsewhere in the app config:
"rabbitmq": {
"resourceQueue": {
"vhost": "resources",
"exchange": "resources_data",
"exchangeType": "topic",
"queue": "resource_queue",
"options": {
"durable": true
}
},
"resourceTopic": {
"vhost": "resources",
"exchange": "resources_data",
"exchangeType": "topic",
"options": {
"durable": true
}
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment