Commit 11572b13 authored by Lukas Burgey's avatar Lukas Burgey

Add checks for the rabbitmq connection and channel

parent 9d568e9e
......@@ -69,7 +69,11 @@ class RabbitMQInstance(models.Model):
@property
def connection(self):
if self.rabbitmq_connection is None:
if (
self.rabbitmq_connection is None
or self.rabbitmq_connection.is_closed
or self.rabbitmq_connection.is_closing
):
rabbitmqconnection_properties = pika.ConnectionParameters(
host=self.host,
ssl=True,
......@@ -83,7 +87,11 @@ class RabbitMQInstance(models.Model):
@property
def channel(self):
if self.rabbitmq_channel is None:
if (
self.rabbitmq_channel is None
or self.rabbitmq_channel.is_closed
or self.rabbitmq_channel.is_closing
):
self.rabbitmq_channel = self.connection.channel()
self.rabbitmq_channel.exchange_declare(
exchange=self.exchange,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment