Wildcards in routingkeys
shurik239 opened this issue · 1 comments
I have still the huge problem using wildcards in routing keys.
What I want to archive:
I have two subscribers:
First one should listen all events in exchange.
Second one should listen only event with specific routing key.
Example implementation you can find below.
If I omit messageType on Publisher - both subscribers are called twice.
If i set messageType to "#" - only second subscriber will be called, but again twice.
I know about issue using messageTypes, but have no idea how can I avoid this with some workaround.
var util = require("util");
var Rabbus = require("rabbus");
var wascally = require("wascally");
wascally.configure({
"connection": {
"server": "localhost",
"vhost": "/",
"user": "guest",
"pass": "guest"
},
"consumerId": "test"
}).then(function () {
var c1 = new Rabbus.Subscriber(wascally, {
exchange: {
name: 'pub-sub.exchange',
type: 'topic'
},
routingKey: "pub-sub.key",
queue: "foo1"
});
c1.subscribe(function(msg, props, actions){
console.log("c1 got it!");
actions.ack();
});
var c2 = new Rabbus.Subscriber(wascally, {
exchange: {
name: 'pub-sub.exchange',
type: 'topic'
},
routingKey: "#",
queue: "foo2"
});
c2.subscribe(function(msg, props, actions){
console.log("c2 got it!");
actions.ack();
});
setTimeout(function () {
function SomePublisher(){
Rabbus.Publisher.call(this, wascally, {
exchange: {
name: 'pub-sub.exchange',
type: 'topic'
},
routingKey: "pub-sub.key",
messageType: "#"
});
}
util.inherits(SomePublisher, Rabbus.Publisher);
var publisher = new SomePublisher();
var message = {
place: "world"
};
publisher.publish(message, function(){
console.log("published a message");
});
}, 250);
});
i'm finally looking into this and am seeing very strange behavior, indeed. i'll have to keep digging, but i suspect that this is caused by wascally's use of postal.js internally. i'm not 100% sure of that, though. i'll let you know what i find.