payapi-rabbus
Version:
A micro-servicebus for RabbitMQ. Forked from https://github.com/derickbailey/rabbus.git solely to make it use payapi-whistlepunk as a dependency.
37 lines (28 loc) • 834 B
JavaScript
var util = require("util");
var rabbot = require("payapi-rabbot");
var Rabbus = require("../../rabbus/lib");
var connection = require("../connection");
// define a subscriber
// -------------------
function SomeSubscriber(){
Rabbus.Subscriber.call(this, rabbot, {
exchange: "pub-sub.exchange",
queue: "pub-sub.q",
routingKey: "pub-sub.key"
});
}
util.inherits(SomeSubscriber, Rabbus.Subscriber);
// connect and subscribe to the published info
// -------------------------------------------
connection(function(){
var sub = new SomeSubscriber();
// basic error handler
sub.use(function(err, msg, props, actions, next){
setTimeout(function(){ throw err; });
});
// subscriber
sub.subscribe(function(msg, props, actions, next){
console.log("1: hello", msg.place);
actions.ack();
});
});