gftea / amqprs

Async & Lock-free RabbitMQ Rust Client, Easy-to-use API
MIT License
214 stars 27 forks source link

ChannelCallback::cancel() not called when server delete queue #112

Closed OverworkedCriminal closed 1 year ago

OverworkedCriminal commented 1 year ago

Hi,

I'm trying to detect unexpected consumer cancellations. Based on https://www.rabbitmq.com/consumer-cancel.html ChannelCallback::cancel() seems to be the best for this, but I can't make it work.

I tried doing something like this:

  1. open connection
  2. register connection callback
  3. open channel
  4. register channel callback
  5. declare queue
  6. channel.basic_consume(...)
  7. remove queue using rabbitmqctl

But ChannelCallback::cancel() was not called.

Did I miss some configuration?

Probable cause

I've read here https://www.rabbitmq.com/connections.html#capabilities that this extension (consumer_cancel_notify) needs to be present in client capabilities, otherwise RabbitMQ does not send any notification.

I modified Connection::open() to check if it would help, and it did. amqprs missing client capabilities

versions: Rust: 1.73 amqprs: 1.5.0

lukebakken commented 1 year ago

Thank you - good job investigating this issue!

@OverworkedCriminal - feel free to open a pull request with your change and, ideally, with a test.

OverworkedCriminal commented 1 year ago

I opened pull request https://github.com/gftea/amqprs/pull/113 (not sure how to link it to this issue) I'll see if i can write test for it

lukebakken commented 1 year ago

@OverworkedCriminal thank you!