Skip to content

Commit 4706404

Browse files
committed
Update readme
1 parent 4714fa4 commit 4706404

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

services/rabbit/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
## Starting a cluster
2+
3+
Make sure all nodes have joined the cluster before using it. Otherwise, number of replicas in quorum queues might be affected. Say, you have a cluster of 3 nodes. You connect to cluster before the 3rd node join it. Your quorum queue would end up with only 2 replicas and will be broken once, 1 node (of 2 nodes holding the replicas of the queue) goes down.
4+
15
## Updating rabbitmq.conf / advanced.config (zero-downtime)
26

3-
rabbitmq.conf and advanced.config changes take effect after a node restart. This can be performed with zero-downtime when RabbitMQ is clustered (have multiple nodes). This can be achieved by stopping and starting rabbitmq nodes one by one
7+
We do not support this automated. But manually this can be achieved in case needed. `rabbitmq.conf` and `advanced.config` changes take effect after a node restart. This can be performed with zero-downtime when RabbitMQ is clustered (have multiple nodes). This can be achieved by stopping and starting rabbitmq nodes one by one
48
* `docker exec -it <container-id> bash`
59
* (inside container) `rabbitmqctl stop_app` and wait some time until node is stopped (can be seen in management ui)
610
* (inside container) `rabbitmqctl start_app`

services/rabbit/docker-compose.yml.j2

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ services:
2626
timeout: 2s
2727
retries: 2
2828
interval: 10s
29-
29+
ports:
30+
- target: 15672
31+
published: 15672
32+
protocol: tcp
33+
mode: host
3034
networks:
3135
- rabbit
3236
configs:
@@ -95,6 +99,8 @@ services:
9599

96100
subscriber:
97101
image: python:3.11
102+
deploy:
103+
replicas: 0
98104
command: sh -c "pip install pika && python /app/sub.py"
99105
environment:
100106
- RABBIT_HOSTS=rabbit_loadbalancer
@@ -107,6 +113,8 @@ services:
107113

108114
publisher:
109115
image: python:3.11
116+
deploy:
117+
replicas: 0
110118
command: sh -c "pip install pika && python /app/pub.py"
111119
environment:
112120
- RABBIT_HOSTS=rabbit_loadbalancer

services/rabbit/test/pub.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import os
3-
import random
43
import time
54

65
import pika
@@ -11,8 +10,15 @@
1110
logger = logging.getLogger(__name__)
1211

1312
host = os.environ["RABBIT_HOSTS"].strip()
14-
credentials = pika.PlainCredentials(os.environ["RABBIT_USER"], os.environ["RABBIT_PASS"])
15-
parameters = pika.ConnectionParameters(host=host, port=5672, credentials=credentials, client_properties={"connection_name": "publisher"})
13+
credentials = pika.PlainCredentials(
14+
os.environ["RABBIT_USER"], os.environ["RABBIT_PASS"]
15+
)
16+
parameters = pika.ConnectionParameters(
17+
host=host,
18+
port=5672,
19+
credentials=credentials,
20+
client_properties={"connection_name": "publisher"},
21+
)
1622

1723
while True:
1824
connection = pika.BlockingConnection(parameters)
@@ -38,4 +44,4 @@
3844
logger.error(
3945
"Verbindung zum RabbitMQ Broker wurde geschlossen. Versuche erneut zu verbinden..."
4046
)
41-
time.sleep(5)
47+
time.sleep(1)

services/rabbit/test/sub.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import os
3-
import random
43
import time
4+
55
import pika
66

77
logging.basicConfig(
@@ -10,8 +10,15 @@
1010
logger = logging.getLogger(__name__)
1111

1212
host = os.environ["RABBIT_HOSTS"].strip()
13-
credentials = pika.PlainCredentials(os.environ["RABBIT_USER"], os.environ["RABBIT_PASS"])
14-
parameters = pika.ConnectionParameters(host=host, port=5672, credentials=credentials, client_properties={"connection_name": "subscriber"})
13+
credentials = pika.PlainCredentials(
14+
os.environ["RABBIT_USER"], os.environ["RABBIT_PASS"]
15+
)
16+
parameters = pika.ConnectionParameters(
17+
host=host,
18+
port=5672,
19+
credentials=credentials,
20+
client_properties={"connection_name": "subscriber"},
21+
)
1522

1623
while True:
1724
logger.info(f"Verbinde zu RabbitMQ Host: {host}")
@@ -36,4 +43,4 @@ def callback(ch, method, properties, body):
3643
logger.error(
3744
"Verbindung zum RabbitMQ Broker wurde geschlossen. Versuche erneut zu verbinden..."
3845
)
39-
time.sleep(5)
46+
time.sleep(1)

0 commit comments

Comments
 (0)