Created
October 1, 2014 18:51
-
-
Save cliftonc/daf8df18f1abf756a86c to your computer and use it in GitHub Desktop.
Example rabbitmq stuff
This file contains 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 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