Skip to content

Instantly share code, notes, and snippets.

@boffbowsh
Created May 21, 2013 18:40
Show Gist options
  • Select an option

  • Save boffbowsh/5622185 to your computer and use it in GitHub Desktop.

Select an option

Save boffbowsh/5622185 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var amqp = require("amqp");
var hostOpts = { host: 'local.vm', login: 'xxx', password: 'xxx' };
var queueName = "email.normal.send";
var connection = amqp.createConnection(hostOpts);
connection.on("ready", function() {
// publish to the default exchange which routes to
// the queue given in the message routing key
connection.exchange("email", {durable: true, type: "direct", confirm: true}, function(exchange) {
var i = 0;
var pushMessage = function() {
console.log("pushMessage");
exchange.on("ack", pushMessage);
exchange.publish(queueName, messageOptions,
{contentType: "application/json", deliveryMode: 2});
i++;
console.log("pushed " + i);
};
pushMessage();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment