bunny
bunny copied to clipboard
Support streaming confirms
From rabbitmq docs:
"To improve throughput, applications are strongly advised to process acknowledgements asynchronously (as a stream) or publish batches of messages and wait for outstanding confirms. The exact API for this varies between client libraries"
Without it the channel is blocked until last publish is confirmed.
I am surprised that confirms callbacks aren't implemented but Bunny::Channel#handle_ack_or_nack
suggests just that :/
@baelter Pretty sure that's exactly how Bunny handles this by default. Tested this yesterday and even with channel.confirm_select
called prior to publishing 20k messages the messages are published in about 9/10 seconds, it's only on channel.wait_for_confirms
that the process is blocked until this call returns with either true
or false
while also populating channel.nacked_sets
with a set of message IDs which were nacked. In my experience it took about 40/60 seconds for the same set of 20k messages.
So yeah, it's not truly streaming confirms but it's efficiently batching publishes and I can't honestly think of a situation (I could be wrong) where you wouldn't want to wait (block) until all confirms have been received.
Definitely this could be improved with some sort of Promise or streaming the reception of confirms in a way that would allow the client to start handling publication failures.