Skip to content

Commit

Permalink
Remove exclusive queue and and use exclusive consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 authored and Brutus5000 committed Dec 12, 2021
1 parent f783a82 commit 9e30d1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions service/message_queue_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ async def listen(
if exchange_name not in self._exchanges:
await self.declare_exchange(exchange_name, exchange_type)

queue = await self._channel.declare_queue(config.QUEUE_NAME, exclusive=True, durable=True)
queue = await self._channel.declare_queue(config.QUEUE_NAME, durable=True)

await queue.bind(exchange=exchange_name, routing_key=routing_key)

await queue.consume(callback)
await queue.consume(callback, exclusive=True)

async def reconnect(self) -> None:
await self.shutdown()
Expand Down
5 changes: 3 additions & 2 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ async def initialize(self):
exchange = await channel.declare_exchange(
config.EXCHANGE_NAME, aio_pika.ExchangeType.TOPIC, durable=True
)
self.queue = await channel.declare_queue("test_queue", exclusive=True)
self.queue = await channel.declare_queue("test_queue", durable=True)

await self.queue.bind(exchange, routing_key="#")
self.consumer_tag = await self.queue.consume(self.callback)
self.consumer_tag = await self.queue.consume(self.callback, exclusive=True)

def callback(self, message):
message.ack()
self.received_messages.append(message)
self._logger.debug("Received message %r", message)
self._callback()
Expand Down

0 comments on commit 9e30d1c

Please sign in to comment.