Fix deprectae warnings with amqp >= 2.x
parent
ad8b2549d7
commit
39dabdb0c8
|
@ -50,17 +50,21 @@ class EventsPushBackend(base.BaseEventsPushBackend):
|
||||||
|
|
||||||
def emit_event(self, message:str, *, routing_key:str, channel:str="events"):
|
def emit_event(self, message:str, *, routing_key:str, channel:str="events"):
|
||||||
connection = _make_rabbitmq_connection(self.url)
|
connection = _make_rabbitmq_connection(self.url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rchannel = connection.channel()
|
connection.connect()
|
||||||
|
except ConnectionRefusedError:
|
||||||
|
log.error("EventsPushBackend: Unable to connect with RabbitMQ at {}".format(self.url),
|
||||||
|
exc_info=True)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
message = AmqpMessage(message)
|
message = AmqpMessage(message)
|
||||||
|
rchannel = connection.channel()
|
||||||
|
|
||||||
rchannel.exchange_declare(exchange=channel, type="topic", auto_delete=True)
|
rchannel.exchange_declare(exchange=channel, type="topic", auto_delete=True)
|
||||||
rchannel.basic_publish(message, routing_key=routing_key, exchange=channel)
|
rchannel.basic_publish(message, routing_key=routing_key, exchange=channel)
|
||||||
rchannel.close()
|
rchannel.close()
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
log.error("Unhandled exception", exc_info=True)
|
log.error("EventsPushBackend: Unhandled exception",
|
||||||
|
exc_info=True)
|
||||||
finally:
|
finally:
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
Loading…
Reference in New Issue