aio pika 等待消息确认到rabbitmq时出现超时异常
我正在使用 aio pika 版本 6.7.1 和 python 3.7.7 以及rabbitmq 3.8.9。
消费者看起来像文档建议:
async with connection:
# Creating channel
channel = await connection.channel()
await channel.set_qos(prefetch_count=self.prefetch_count)
# Declaring exchange
exchange = await channel.declare_exchange(
'EX', ExchangeType.TOPIC, durable=True
)
# Declaring queue
queue = await channel.declare_queue(self.queue_name, durable=True)
# Bind queue to exchange
await queue.bind(exchange)
async with queue.iterator() as iter:
async for message in iter:
try:
await self.do_stuff_to_message(message)
await message.ack()
except Exception as e:
await self.processor.handle_failure(e, message)
但是收到“asyncio.TimeoutError from None”错误 - 它只能通过从 message.ack() 中删除等待来解决。
原因是什么以及正确的使用方法是什么?
I`m using aio pika version 6.7.1 with python 3.7.7 with rabbitmq 3.8.9.
the consumer looks like the documentations suggests:
async with connection:
# Creating channel
channel = await connection.channel()
await channel.set_qos(prefetch_count=self.prefetch_count)
# Declaring exchange
exchange = await channel.declare_exchange(
'EX', ExchangeType.TOPIC, durable=True
)
# Declaring queue
queue = await channel.declare_queue(self.queue_name, durable=True)
# Bind queue to exchange
await queue.bind(exchange)
async with queue.iterator() as iter:
async for message in iter:
try:
await self.do_stuff_to_message(message)
await message.ack()
except Exception as e:
await self.processor.handle_failure(e, message)
but gets "asyncio.TimeoutError from None" errors -
its only solved by removing the await from message.ack().
what is the reason and what is the correct use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论