cloudamqp / amqp-client.cr

An AMQP 0-9-1 client for Crystal
https://cloudamqp.github.io/amqp-client.cr/
MIT License
69 stars 10 forks source link

channel#basic_cancel #16

Closed antondalgren closed 4 years ago

antondalgren commented 4 years ago

Subscriber should still process the messages it's assigned to

This method cancels a consumer. This does not affect already delivered messages, but it does mean the server will not send any more messages for that consumer. The client may receive an arbitrary number of messages in between sending the cancel method and receiving the cancel-ok reply. https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.cancel

Co-authored-by: Anders Bälter anders@84codes.com

carlhoerberg commented 4 years ago

or better yet, send Cancel with no_wait = false and then on CancelOk from the server we delete the consumer.

baelter commented 4 years ago

or better yet, send Cancel with no_wait = false and then on CancelOk from the server we delete the consumer. @carlhoerberg If we have high prefetch there might still be unhandeld messages when we get CancelOk

carlhoerberg commented 4 years ago

Ok, but then maybe send a special message on the @deliveries channel in Channel, when a CancelOk comes in. So that it is the delivery loop method that deletes the callback function

carlhoerberg commented 4 years ago

currently all messages to a channel are processed on a single fiber. wondering if would be a better idea to have a fiber per consumer instead. and then we close that fiber when we get the CancelOk

antondalgren commented 4 years ago

Your changes looks good to me! @carlhoerberg 🚀 🎉