Home > Enterprise >  How to check rabbitMQ connection(health check) up or not?
How to check rabbitMQ connection(health check) up or not?

Time:11-10

I'm running 4 microservice using docker. Here one service depends on other services. That is why I need to check before using any service other services up or not?

To up all services I'm writing a bash script. For my working purpose, I am using sleep until up properly rabbitmq.

what is the better solution to check rabbitmq up or not? Until not up rabbitmq I have to wait. Now for my working pupose i am using like that -

# wait for rabbitmq container be ready 
sleep 14

This is the docker-compose container for rabbitMQ

rabbitmq:
image: 'rabbitmq:3.8.9'
container_name: rabbitmq_dev
restart: always
ports:
  - 5675:5672
environment:
  - RABBITMQ_DEFAULT_USER=rabbit
  - RABBITMQ_DEFAULT_PASS=pass
depends_on:
  - consul
networks:
  - my_networks

CodePudding user response:

I think HealthCheck can solve your problem.

Reference links: Docker Compose wait for container X before starting Y

  • Related