Fix the cancellation flow to avoid multiple invocations of basic.cancel #55
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There are two flows to shutdown the RabbitMQ consumers. When the plugin is the one shutting it down, it should send a channel cancellation message by invoking
@hare_info.channel.basic_cancel(@consumer.consumer_tag)
and waiting for the consumer to terminate (once the broker replies with abasic.cancel-ok
message). This back-and-forth is handled by the MarchHare client. On the other hand, when the broker requests the client to shut down (eg. due to queue deletion). It sends the client abasic.cancel
message, which is handled internally by the client (handleCancel
), unregistering the consumer and then invoking the:on_cancellation
callback. In that case, the plugin should not do anything as the consumer is already canceled/unregistered.This PR adds an extra condition on the shutdown to check whether the client is already canceled/terminated (by the broker) or if it should execute the plugin cancellation flow.
Closes: #40