I have a publisher, which publishes messages to rabbitmq://localhost/test123 queue. One message has TestMessage type, the other TestMessage2 type.
Publisher config:
sbc.UseRabbitMq(r => r.ConfigureHost(new MessageUrn("rabbitmq://localhost/test123"), c => { }));
sbc.UseLog4Net();
sbc.UseJsonSerializer();
sbc.EnableMessageTracing();
sbc.ReceiveFrom(new MessageUrn("rabbitmq://localhost/test123"));
I have two seprate consumers per message type (2 consumers), consumer 1:
//config stuff
sbc.ReceiveFrom("rabbitmq://localhost/test678?prefetch=20");
sbc.Subscribe(subs => { subs.Handler<TestMessage>(msg => { Logger.Info(msg.Text); }); });
consumer 2:
//config stuff
sbc.ReceiveFrom("rabbitmq://localhost/test678");
sbc.Subscribe(
subs =>
{
subs.Handler<TestMessage2>(
msg => { Logger.Info(String.Format("rcv:txt= {0}, number= {1}", msg.Text, msg.Number)); });
});
So when I stop publisher and run one of the consumers, he consumes all messages of his type and move other to error queue. Exchange for test678 has bindings for both types.
Is it normal behavior that 2 different consumers will try to read their message while moving other messages to error queue? Why I can't share one queue among different consumers with different interested types?
(I believe it is not masstransit issue, rather rabbitmq design considerations or limitation)
Thanks in advance.
If you have more than one service bus instance receiving from the same queue, you need to ensure that the consumers registered on that service bus instance are the same. Otherwise, messages consumed by the service will be moved to the _error queue for message type which have no consumer on that service instance.