Created
March 19, 2014 13:25
-
-
Save DarcInc/9641557 to your computer and use it in GitHub Desktop.
Node AMQ Message Producer
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 queueName = 'tasks'; | |
var exchangeName = 'taskExchange'; | |
var key = 'all'; | |
var amq = require('amq'); | |
var readline = require('readline'); | |
var connection = amq.createConnection( | |
{ host: 'localhost', debug: true }, | |
{ reconnect: { strategy: 'constant', initial: 1000 } } | |
); | |
rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
var queue = connection.queue(queueName, { durable: true }); | |
var exchange = connection.exchange(exchangeName, { durable: true, type: 'topic', confirm: true }); | |
queue.bind(exchange, key); | |
rl.setPrompt("> "); | |
rl.prompt(); | |
rl.on('line', function(line) { | |
line = line.trim(); | |
exchange.publish(key, line); | |
rl.prompt(); | |
}); | |
connection.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment