Closed bmario closed 5 years ago
I'm experiencing the same problem: Unknown u'<pamqp.specification.Basic.Ack object at 0x7fd111ddc8d0>' from broker
.
@decaz how I may reproduce it?
@mosquito this problem appears when trying to publish messages to exchange with no queue binded to it. For instance:
import asyncio
import aio_pika
async def main():
connection = await aio_pika.connect_robust('amqp://guest:guest@127.0.0.1/')
channel = await connection.channel()
i = 0
while True:
msg = aio_pika.Message(body=f'Message {i}'.encode())
await channel.default_exchange.publish(msg, routing_key='nonexisting_queue')
print('Published', i)
await asyncio.sleep(1)
i += 1
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
Make sure there is not queue named "nonexisting_queue" and run the script:
$ python publisher.py
Published 0
Unknown <pamqp.specification.Basic.Ack object at 0x7f06bcb5bbe0> from broker
Published 1
Unknown <pamqp.specification.Basic.Ack object at 0x7f06bcb5bb38> from broker
Published 2
Unknown <pamqp.specification.Basic.Ack object at 0x7f06bcb5bb70> from broker
...
Fixed in aiormq==2.1.1
When I publish messages to an exchange for which there is no route, I get the following message for each publish:
What I found out from my investigation is that by default the
mandatory
flag is set to True, which tells the RabbitMQ server to answer with aReturn
frame and anAck
frame. However, theChannel
clears out the Promise in theself.confirmations
already in the_on_return
method. Thus, theAck
will complain by printing the above message.On a side note: I find the default settings questionable, as
mandatory
is set to true, but theon_return_raises
flag is false. I'd either want to silently drop the message if it's not routable, or that an exception is raised.