0.3.0 • Published 14 years ago
pulse v0.3.0
node-pulse
This is a node.js library for listening to Mozilla Pulse messages.
Installation
npm install pulseUsage
var pulse = require("pulse");
var callback = function(message) {
console.info("Success! Your connection works, and you just recieved this:");
console.info(message);
console.info("Now closing connection...");
conn.close();
}
var conn = pulse.createConsumer("test", "node-pulse-test");
conn.on("message", callback);Consumers
Consumers are created by the createConsumer method and are instances of events.EventEmitter. Consumers emit two events:
- message
- error
createConsumer(type, name , topics)
Creates a Consumer with the queue name name and listens to all the topics specified by the topics. topics can be an array of topics, a single topic, or if omitted, will default to all topics on the exchange (#). This method supports the following arguments for type:
test- binds to messages on theorg.mozilla.exchange.pulse.testexchange.meta- binds to messages on theorg.mozilla.exchange.pulseexchange.bugzilla- binds to messages on theorg.mozilla.exchange.bugzillaexchange.code- binds to messages on theorg.mozilla.exchange.codeexchange.build- binds to messages on theorg.mozilla.exchange.buildexchange.
Consumer.close()
Closes the connection to the Pulse server.
Event: message
function(message) { }
Dispatched whenever a new message is received from Pulse.
Event: error
function(error) { }
Dispatched whenever this is an amqp error with the connection.