NServiceBus + RabbitMQ transport - bus start when rabbit connection is available


(Crane Senior) #1

I have a question, I try to make a messages flow using NServiceBus with RabbitMQ transport.
I made some code and there I have a one line in my subscriber:


There may be a black scenario with network connection issues or something and then Create method will fail because it won’t connect to Rabbit.

Is there a way to handle the situation and Start the created Bus when Create method complete successfully?
Can I repeat Bus.Create method in loop in try-catch block without any opposites?


(Daniel Marbach) #2

Hi Crane,

I would not recommend you to reuse the same BusConfiguration object per create call. You’d need to create a new BusConfiguration object for retry attempt but then it should work.

But first and foremost instead of trying to fix things with code I would investigate the network connectivity issues and try to solve it from that angle. RabbitMQ is something you rely on not only while starting but also when operating. While the connection is reestablished internally when it is lost during runtime I’d still argue you want to make sure you have a stable network link. What you see happening during bus creation might be an indication for something off in your network.


(Crane Senior) #3

Hey, thanks for reply,

everytime I am using Create method I create new BusConfiguration object for that purpose.

I have checked my retries solution, I make a retry every 10 seconds if there are any exceptions (made new busConfiguration, set everything and invoke line from the first comment: Bus.Create(busConfiguration).Start();).

I started rabbit 1 minute after my component and immediately saw 17 connections in rabbit Console. I tested it on my local machine with just one instance of my component (subscriber).

And there is one important thing i forget to mention earlier, I am using NServiceBus.RabbitMQ version 3.5.2 and NServiceBus version 5.2.24

EDIT: the connections I saw in Rabbit console - almost all of them was ‘Administration’ connections, except 1 that was ‘Consume’.

(Daniel Marbach) #4

Hi Crane,

Is there anything else you need to know from us? I wasn’t sure after your last reply. Just double checking here


(Crane Senior) #5

no thanks, I solved all my problems thanks to Your previous reply.