bunny icon indicating copy to clipboard operation
bunny copied to clipboard

`basic_cancel` makes other channels wait

Open route opened this issue 1 year ago • 0 comments

RabbitMQ 3.12.13 Erlang 25.3.2.12 bunny 2.22.0

Scenario - I need to cancel a few consumers from one or a few channels, I call:

channels.each { |ch| ch.basic_cancel(consumer_tag) }

It should do the job, but there's a call inside basic_cancel:

@work_pool.shutdown(true) unless self.any_consumers?

which makes it wait (if that was the last consumer) until current job finishes before going to the next channel, which makes next channel accept incoming messages again and again, which makes cancellation not as efficient as it could be. I wish there was a way to do the same thing in an async way, so that cancel is cancel @connection.send_frame(AMQ::Protocol::Basic::Cancel.encode(@id, consumer_tag, false)) and nothing more fancy.

In general I'd like to give some time to current jobs to be processed, stop accepting new jobs thus cancelling all consumers, and when current jobs are finished close connection and channels gracefully. I don't think it's currently possible with one simple call in the lib.

route avatar Jun 19 '24 09:06 route