How to wait for rabbitmq to accept connections in docker compose ?
I have a similar setup to the following snippet
version: "3.9"
services:
rabbitmq:
image: rabbitmq:management
service_A:
depends_on:
- rabbitmq
service_B:
depends_on:
- rabbitmq
When I run docker compose up
It doesn't wait for rabbitmq to fully load, Instead it runs service_A and service_B. When both of the services run, It tries to connect to rabbitmq and fails and exists then after a while rabbitmq is ready to accept connections.
Is there a standard way to handle this situation, or even a hack to go around this issue ?
- note: both services are written in rust and using
lapin
crate to connect to rabbitmq.