Hi, I'm using MassTransit 3.5.2 and I've noticed strange behavior when I try to start the bus,
but RabbitMQ service is not running.
Consider the following example:
public async Task Test()
{
IBusControl busControl = Bus.Factory.CreateUsingRabbitMq(x =>
{
var host = sbc.Host(new Uri("rabbitmq://localhost"), h =>
{
h.Username("guest");
h.Password("guest");
});
sbc.ReceiveEndpoint(host, "test_queue", ep =>
{
ep.Handler<YourMessage>(context =>
{
return Console.Out.WriteLineAsync($"Received: {context.Message.Text}");
});
});
});
BusHandle handle = null;
try
{
// Throws an exception because RabbitMQ is not running
handle = await busControl.StartAsync();
}
catch (RabbitMqconnectionexception ex)
{
// Should throw another exception, but it doesn't
handle = await busControl.StartAsync();
}
}
So the first call to bus start fails like it should, but the second and all other subsequent calls actually pass.
Is this a normal behavior, because I would expect the exception every time the bus fails to start?