Home > Blockchain >  Is there a way to restart the bus using RabbitMq with MassTransit?
Is there a way to restart the bus using RabbitMq with MassTransit?

Time:12-13

I want to restart the bus connection using RabbitMq with MassTransit, the first idea was to stop the connection and start it again but this did not work. Is there something more specific or a better way to do that?

await bus.StopAsync();
await bus.StartAsync(source.Token);

CodePudding user response:

Assuming you are on a current version of MassTransit, you can do exactly that to restart the bus.

You can see in this unit test that the bus is started and stopped without issue.

await bus.StartAsync(TestCancellationToken);
await bus.StopAsync(TestCancellationToken);

await bus.StartAsync(TestCancellationToken);
await bus.StopAsync(TestCancellationToken);
  • Related