Polyconseil / aioamqp

AMQP implementation using asyncio
Other
280 stars 88 forks source link

Add consumer cancellation callback #178

Closed dave-shawley closed 5 years ago

dave-shawley commented 5 years ago

RabbitMQ has the concept of the broker sending a basic.cancel to the consumer when the queue that the consumer is connected to is deleted (see Consumer Cancel Notification). aioamqp has direct support for receiving cancellations but no way to react to them. The result is that cancelled consumers are simply never called again.

The PR adds a new method to the channel to register callbacks that are invoked when a channel receives a cancellation notification. I considered invoking the error callback on the connection but that could lead to problems for projects that are currently using it. Another alternative would be to add a similar error callback for the channel that is invoked with a specific exception when cancellation occurs.

I'm open to any of the alternatives. This PR is one possible way to solve the problem. Let me know if you want to approach this in some other way.

dzen commented 5 years ago

Hi @dave-shawley,

We're on our way for an offsite, we won't be able to merge it this week.

dave-shawley commented 5 years ago

@dzen Thank you for the wonderful library and quick response. The merge isn't pressing so it can wait until you return from your offsite.