Issue when starting a bus

48 views
Skip to first unread message

Milos Medic

unread,
Mar 22, 2017, 9:18:24 AM3/22/17
to masstransit-discuss
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?

Дмитрий Ушенко

unread,
Apr 26, 2017, 10:59:51 AM4/26/17
to masstransit-discuss
This is notmal behavior. Just continue execution by hitting F5. Or you can tune Exception Settings in Visual Studio. 

среда, 22 марта 2017 г., 16:18:24 UTC+3 пользователь Milos Medic написал:

Mikael Johansson

unread,
May 3, 2017, 5:25:42 AM5/3/17
to masstransit-discuss
Is it normal to throw an exception first time and not doing it the second time even when RabbitMQ is not running? 

How should he then know when it did work or did not work?

Дмитрий Ушенко

unread,
May 4, 2017, 5:24:33 AM5/4/17
to masstransit-discuss
Whatever is was, this exception comes from the RabbitMq.Client assembly. So if you really want to know is it normal or not you should ask Pivotal. I think that ConnectFailureException (exact exception that you see) is not a fatal, but BrokerUnreachableException is fatal. When RabbitMQ is not running you will see BrokerUnreachableException.

среда, 3 мая 2017 г., 12:25:42 UTC+3 пользователь Mikael Johansson написал:

Chris Patterson

unread,
May 4, 2017, 11:36:11 AM5/4/17
to masstrans...@googlegroups.com
If you're talking about the exception thrown deep within the RabbitMQ.Client when debugging, yeah, it's annoying. But it isn't fatal. You can tell the debugger to ignore exceptions thrown within that assembly. In fact, the exception you're talking about doesn't ever make it to MT.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/64dffa08-c212-4046-a064-a69423ea9b65%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages