From bf5c760a9569ba07ae5c88f2c21eeb3d8c5580be Mon Sep 17 00:00:00 2001 From: Maxim Kolyubyakin Date: Mon, 20 Mar 2023 10:08:53 +0100 Subject: [PATCH] LITE-26790 RMQ Connection is cleaned in any error case --- dj_cqrs/transport/rabbit_mq.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dj_cqrs/transport/rabbit_mq.py b/dj_cqrs/transport/rabbit_mq.py index dddb5f0..478763e 100644 --- a/dj_cqrs/transport/rabbit_mq.py +++ b/dj_cqrs/transport/rabbit_mq.py @@ -114,10 +114,12 @@ def _produce_with_retries(cls, payload, retries): exceptions.ReentrancyError, AMQPConnectorException, ) as e: + # in case of any error - close connection and try to reconnect + cls.clean_connection() + base_log_message = "CQRS couldn't be published: pk = {0} ({1}).".format( payload.pk, payload.cqrs_id, ) - if not retries: logger.exception(base_log_message) return @@ -126,8 +128,6 @@ def _produce_with_retries(cls, payload, retries): base_log_message, e.__class__.__name__, )) - # in case of any error - close connection and try to reconnect - cls.clean_connection() cls._produce_with_retries(payload, retries - 1) @classmethod