question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MassTransit blocks service start process when RabbitMQ service is unreachable

See original GitHub issue

We use services.AddMassTransit to configure MassTransit. To test the behavior if RabbitMQ service is down at startup, I stopped the service and ran the .net core 3 web api. The following is the result. It complains about unreachable Broker, nothing works during this time service and healthcheck endpoints of the api are unreachable. When I start the service, Kestrel initializes and service starts to work as desired.

Question 1 : How to initialize and run the api like normal under this situation. This means controllers and healthchecks would be running.

Question 2 : Is there a .net core 3 sample that demonstrates, health check implementation on MassTransit.

RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
------- Start RabbitMQ service-----
RabbitMQ Connect Failed: Broker unreachable: admin@localhost:5672/myapp
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://localhost:8110'. Binding to endpoints defined in UseKestrel() instead.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
phatboygcommented, Mar 20, 2020

The real goal here is to allow the web site to start but support the readiness and healthy checks for the endpoints. So if the broker isn’t connected, it isn’t ready until the broker connection is established.

1reaction
phatboygcommented, Dec 18, 2019

Yes, pass a cancellationToken with the timeout of your choice. I believe there is even an overload that does this for you if you pass a TimeSpan.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MassTransit how to handle Start/Stop when Queue is down
It depends on how you want you system to react in case RabbitMQ is down. If you need to take an action (restart...
Read more >
How to handle "broker unreachable" during bus.Start() as if ...
In my environment, if RabbitMQ is unreachable it's most probably a transient issue, so I'd rather have my application start normally while ...
Read more >
Messaging through a service bus in .NET using MassTransit ...
Start the RabbitMQ service again. After a couple of seconds the MassTransit bus will be up again and the “connection failed” messages will...
Read more >
Error Handling in MassTransit Consumers
If the process hosting our consumer service dies before acknowledging the message, RabbitMQ will move the message back to the “Ready” state.
Read more >
Transaction Filter
The message pipeline in MassTransit is asynchronous, leveraging the Task ... But that also means that the method blocks the thread while the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found