MassTransit blocks service start process when RabbitMQ service is unreachable
See original GitHub issueWe 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:
- Created 4 years ago
- Reactions:1
- Comments:18 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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
.