RMQ and DB: Added reconnecting to either if the application goes down
This commit is contained in:
1 parent
482a90ae7b
commit
ac6ca4baf8
3 files changed
+17
-3
No files matched your search
@@ -41,7 +41,8 @@ def create_connection():
|
||||
|
||||
def send_message_to_rmq(connection, user_id: int, message: Dict):
|
||||
if not connection or not connection.is_open:
|
||||
raise RuntimeError("RabbitMQ connection is not open")
|
||||
print("[RMQ] Connection lost, reconnecting...")
|
||||
connection = create_connection()
|
||||
|
||||
channel = connection.channel()
|
||||
channel.exchange_declare(exchange=rmq_exchange, exchange_type="topic", durable=True)
|
||||
|
||||
Reference in new issue
Block a user