Reputation: 145
We are using RabbitMQ and MassTransit as our messaging infrastructure in out application.
I have a scenario where my consumer needs to stop processing messages for a while and then restarted at some later point.
I can successfully stop the bus and consumer stops processing further messages but when I restart the bus it says bus already started, but the consumer won't pickup any more messages for further processing
Sample code looks like
var iBusControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
{
var host = cfg.Host(new Uri("rabbitmq://localhost"), h =>
{
h.Username("guest");
h.Password("guest");
});
if (linkConsumer)
cfg.ReceiveEndpoint("TestMessage_Queue", x =>
{
x.Consumer<TestMessageConsumer>();
});
});
iBusControl.Start();
// Consumer starts processing messages
// later on in the code I call stop on the same bus instance
iBusControl.Stop();
// Consumer stops processing messages
// later on in the code I call start again on the bus instance
iBusControl.Start();
// Masstransit also says, bus already started
// But the consumer won't pick up any further messages for processing.
Bus if I create a new instance of the bus same as the first block of my code and call start on it, it will connect the consumer correctly and message processing starts again. Few questions/confusions
Using MassTransit 5.3.3 with RabbitMQ 3.6.14 Erlang 20.1
Upvotes: 1
Views: 1178
Reputation: 1675
With the release of masstransit v7.1.0, the bus can be restarted after being stopped. Before that, this was not possible.
From the release notes:
Since MassTransit's inception, it has never been possible to Start a bus that was previously Started and then Stopped. With this release, a bus can now be started, stopped, started, and stopped, and started, and stopped...
Upvotes: 2