Skip to content

Commit 7e2c45d

Browse files
committed
fix: Switch from Azure Service Bus to RabbitMQ for task queue
Azure Service Bus is incompatible with Kombu 5.x used by Celery 5.3.6. All versions of azure-servicebus 7.x have breaking module structure changes that prevent Kombu from connecting, causing production worker failures. Changes: - Remove hardcoded LOKOLE_QUEUE_BROKER_SCHEME=azureservicebus from docker-compose.prod.yml - Add RabbitMQ service (rabbitmq:management-alpine) to production compose - Worker now depends on RabbitMQ service - Add URL encoding for broker credentials to handle special characters (/, =, +) - Add rabbitmq_data volume for queue persistence - Uses existing credentials (LOKOLE_EMAIL_SERVER_QUEUES_SAS_NAME/KEY) for RabbitMQ auth Production setup: Add these two lines to secrets/azure.env: LOKOLE_QUEUE_BROKER_SCHEME=amqp LOKOLE_EMAIL_SERVER_QUEUES_NAMESPACE=rabbitmq This fixes the production worker failures with TypeError and RuntimeError when trying to connect to Azure Service Bus.
1 parent 45bb3b5 commit 7e2c45d

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

docker/docker-compose.prod.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ x-shared-secret-environment:
77
HOST: 0.0.0.0
88
WEBAPP_PORT: 8080
99
LOKOLE_STORAGE_PROVIDER: AZURE_BLOBS
10-
LOKOLE_QUEUE_BROKER_SCHEME: azureservicebus
1110
CONNEXION_SPEC: dir:/app/opwen_email_server/swagger
1211
CELERY_QUEUE_NAMES: all
1312
TESTING_UI: "False"
@@ -44,3 +43,21 @@ services:
4443
image: ascoderu/opwenserver_app:latest
4544
command: ["/app/docker/app/run-celery.sh"]
4645
<<: *shared-secret-environment
46+
depends_on:
47+
- rabbitmq
48+
49+
rabbitmq:
50+
image: rabbitmq:management-alpine
51+
environment:
52+
# Use same creds from azure.env for convenience
53+
RABBITMQ_DEFAULT_USER: ${LOKOLE_EMAIL_SERVER_QUEUES_SAS_NAME}
54+
RABBITMQ_DEFAULT_PASS: ${LOKOLE_EMAIL_SERVER_QUEUES_SAS_KEY}
55+
volumes:
56+
- rabbitmq_data:/var/lib/rabbitmq
57+
restart: always
58+
# Optional: expose management UI
59+
# ports:
60+
# - 15672:15672
61+
62+
volumes:
63+
rabbitmq_data:

opwen_email_server/config.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from urllib.parse import quote
2+
13
from environs import Env
24

35
env = Env()
@@ -65,6 +67,9 @@
6567
QUEUE_BROKER_PASSWORD = env('LOKOLE_EMAIL_SERVER_QUEUES_SAS_KEY')
6668
QUEUE_BROKER_HOST = env('LOKOLE_EMAIL_SERVER_QUEUES_NAMESPACE')
6769
if env('LOKOLE_QUEUE_BROKER_SCHEME', ''):
68-
QUEUE_BROKER = f"{QUEUE_BROKER_SCHEME}://{QUEUE_BROKER_USERNAME}:{QUEUE_BROKER_PASSWORD}@{QUEUE_BROKER_HOST}"
70+
# URL-encode credentials to handle special characters
71+
username = quote(QUEUE_BROKER_USERNAME, safe='')
72+
password = quote(QUEUE_BROKER_PASSWORD, safe='')
73+
QUEUE_BROKER = f"{QUEUE_BROKER_SCHEME}://{username}:{password}@{QUEUE_BROKER_HOST}"
6974
else:
7075
QUEUE_BROKER = env('LOKOLE_QUEUE_BROKER_URL', '')

0 commit comments

Comments
 (0)