MassTransit: MassTransit blocks service start process when RabbitMQ service is unreachable
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 18 (11 by maintainers)
Commits related to this issue
- Changes for #1644 to not block startup and allow the liveness,readiness checks to be used to verify startup complete. — committed to phatboyg/MassTransit by phatboyg 4 years ago
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.