mosquito / aiormq

Pure python AMQP 0.9.1 asynchronous client library
Other
276 stars 58 forks source link

Unknown <pamqp.specification.Basic.Ack object at 0x1043e5a58> from broker #9

Closed bmario closed 5 years ago

bmario commented 5 years ago

When I publish messages to an exchange for which there is no route, I get the following message for each publish:

Unknown <pamqp.specification.Basic.Ack object at 0x1043e5a58> from broker

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 a Return frame and an Ack frame. However, the Channel clears out the Promise in the self.confirmations already in the _on_return method. Thus, the Ack will complain by printing the above message.

On a side note: I find the default settings questionable, as mandatory is set to true, but the on_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.

decaz commented 5 years ago

I'm experiencing the same problem: Unknown u'<pamqp.specification.Basic.Ack object at 0x7fd111ddc8d0>' from broker.

mosquito commented 5 years ago

@decaz how I may reproduce it?

decaz commented 5 years ago

@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
...
mosquito commented 5 years ago

Fixed in aiormq==2.1.1