Answer the question
In order to leave comments, you need to log in
RabbitMQ: consumer question?
I can’t deal with RabbitMQ with consumer in any way.
I launch my containers through docker-compose, everything seems to work, queues are created, the consumer also reports that he has connected, but does not receive a queue. If I manually restart the consumer, it picks up all the queues that were and starts picking up new ones immediately.
As far as I understand, until there is at least one message in the queue, the consumer does not see or receive them.
And I don’t understand, do I need to somehow review the logic of the services, or docker-compose file?
Here is the docker-compose file:
version: "3.1"
services:
http:
container_name: "http_pr"
build:
context: "./"
dockerfile: "./docker/http.Dockerfile"
ports:
- "8085:8085"
# links:
# - "grpc:grpc"
environment:
PORT_HTTP: ":8085"
GRPC: "grpc:9000"
RMQ_PATH: "rabbitmq-broker:5672/"
RMQ_LOG: "guest"
RMQ_PASS: "guest"
depends_on:
- rabbitmq-broker
grpc:
container_name: "grpc"
build:
context: "./"
dockerfile: "./docker/grpc.Dockerfile"
ports:
- "9000:9000"
environment:
TCP_PORT: ":9000"
DB_TYPE: "inmemory"
rabbitmq-broker:
image: rabbitmq:management-alpine
container_name: "rabbitmq-broker"
hostname: rabbitmq-broker
ports:
- 5672:5672 # for sender and consumer connections
- 15672:15672
volumes:
- ./rabbitmq/data/:/var/lib/rabbitmq
- ./rabbitmq/log/:/var/log/rabbitmq
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_PASS: "guest"
RABBITMQ_DEFAULT_USER: "guest"
# RABBITMQ_DEFAULT_VHOST: "/"
consumer:
build:
context: "./"
dockerfile: "./docker/consumer.Dockerfile"
depends_on:
- rabbitmq-broker
- http
environment:
RMQ_PATH: "rabbitmq-broker:5672/"
RMQ_LOG: "guest"
RMQ_PASS: "guest"
restart: on-failure
Answer the question
In order to leave comments, you need to log in
Where is the message published, in the exchanger? Who creates the queue and binding to the exchanger? Can it happen that if the queue and binding are created by the consumer, then at the time of their creation the exchanger does not yet exist and an error occurs that is ignored? Since there is a management plugin in the container, you can see the state of the system at the moment when messages are not received by the consumer: is there a queue, an exchanger, bingding between them, a queue consumer.
But also do not forget that if the publisher starts first, and then the consumer, then with missing queues, you can lose messages. Ideally, some kind of initialization script should create the entire infrastructure of exchangers and queues, before the start of the main applications (something similar to running database migrations). But this can also be done withRabbitMQ itself .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question