I am trying to setup docker compose with 3 services: 1 rabbitmq service and 2 java applications(1 producer and 1 consumer). When rabbitmq service starts, it has no queues by default. Only when produces send message to queue it actually creates it. In the same time, consumer requires queue which it has listen to. So here is the problem: when i run my docker compose, rabbitmq starts fine with my producer, but consumer can't find queue and fails. So, can i somehow set-up docker compose rabbitmq service to start and create queue by default?
version: '3.3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
restart: always
environment:
RABBITMQ_DEFAULT_USER: help
RABBITMQ_DEFAULT_PASS: 51243
ports:
- "5672:5672"
- "15672:15672"
@Update I found pretty good way to achieve what i want. I can start rabbitmq, create all what i need(queue) and export definitions.json. Then i need put it under /etc/rabbitmq/definitions.json
version: '3.3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
restart: always
environment:
RABBITMQ_DEFAULT_USER: ete
RABBITMQ_DEFAULT_PASS: 1402
ports:
- "5672:5672"
- "15672:15672"
volumes:
- ./definitions.json:/etc/rabbitmq/definitions.json
But here is another problem: this definition file overrides my user that i set by environment variables. Here is definition.json:
{
"rabbit_version": "3.8.9",
"rabbitmq_version": "3.8.9",
"product_name": "RabbitMQ",
"product_version": "3.8.9",
"users": [
{
"name": "eternal",
"password_hash": "wz1jzbGjNMZ115U7XhEUvF271uImnOfho2jpx2pOvLSY/Ssl",
"hashing_algorithm": "rabbit_password_hashing_sha256",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "/"
}
],
"permissions": [
{
"user": "eternal",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"topic_permissions": [],
"parameters": [],
"global_parameters": [
{
"name": "cluster_name",
"value": "rabbit@58cb492cd4ee"
},
{
"name": "internal_cluster_id",
"value": "rabbitmq-cluster-id-DlZ_FZVpiFx93CVZXneG4A"
}
],
"policies": [],
"queues": [
{
"name": "qqq",
"vhost": "/",
"durable": false,
"auto_delete": false,
"arguments": {}
}
],
"exchanges": [],
"bindings": []
}
If i will remove users section and everything else and keep only queue section, then after docker-compose up, i can't log in into managment page. Because my login and password is not accepted.