hreinhardt/amqp

Support Consumer Cancellation Notification

Closed this issue · 10 comments

First of all - thanx for this AMQP library!

In addition to the cool things the library already supports I would suggest Consumer Cancellation Notification as described in https://www.rabbitmq.com/consumer-cancel.html

I think to support this the following would be needed:

  • clientProperties in function start_ok within openConnection'' would need to add key "capabilities" with the value being a table containing "consumer_cancel_notify" = FVBool True (see https://www.rabbitmq.com/consumer-cancel.html#capabilities)
  • the channelReceiver would need a function handleAsync (SimpleMethod (Basic_cancel ... to handle the event and dispatch the registered Consumer Cancellation Notification handlers
  • a new function addConsumerCancellationHandler to register such a callback

I hope I have not missed something vital.

What do you think?

This sounds like a useful feature and I think your list of tasks should be correct. Do you want to implement this and submit a pull-request?

I'm not sure I understand enough of the underlying AMQP protocol but I'll give it a try.

@nikomi you seem to be understanding that extension and how client capabilities are used quite well :) But still I feel this overview is worth mentioning. When in doubt, see how other clients do it ;)

Thanx for the thumbs-up but my estimation of the work to be done just came from being able to read the code - I can see where the pieces might fit but I have no clue if I catch everything, e.g. what's the second parameter in basic.cancel for in this case (I decided to ignore it) or do I need to send back a basic.cancel_ok to the server (I guess not).

Nevertheless I have committed the change but I can't test it until Monday when I get back to my office. If you want to I can create a pull request so you can review (or maybe even test) it.

Feel free to open the pull-request whenever you have time.

Regarding your issues, I would agree with both of your assumptions, but I'm not sure myself.

Created Pull Request #79

Created Pull Request #80 with requested fixes

@nikomi FYI, you don't have to open a new pull request when you want to submit a change. Pushing (or force pushing, if you have to e.g. rebase) to a branch updates its PR.

Thx for info!

Resolved by #80