Skip to content

Commit 16c7d80

Browse files
authored
Merge pull request #18 from cloudblue/bugfix/LITE-17486-closing-connection-not-handled
LITE-17486 Fix producer rabbit shared connection to handle close connection exceptions
2 parents 575fc21 + 69c07d6 commit 16c7d80

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dj_cqrs/transport/rabbit_mq.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ class RabbitMQTransport(LoggingMixin, BaseTransport):
2828

2929
@classmethod
3030
def clean_connection(cls):
31-
if cls._producer_connection and not cls._producer_connection.is_closed:
32-
cls._producer_connection.close()
31+
connection = cls._producer_connection
32+
if connection and not connection.is_closed:
33+
try:
34+
connection.close()
35+
except (exceptions.StreamLostError, exceptions.ConnectionClosed, ConnectionError):
36+
logger.warning("Connection was closed or is closing. Skip it...")
3337

3438
cls._producer_connection = None
3539
cls._producer_channel = None

0 commit comments

Comments
 (0)