tortoise icon indicating copy to clipboard operation
tortoise copied to clipboard

How to provide backpressure when too many incoming messages?

Open RKushnir opened this issue 1 year ago • 0 comments

Hi, thanks for making this package available to everyone.

I'd like your help to know what to do when my downstream service can't keep up with the rate of incoming messages. Tortoise.Handler.handle_message/3 is expected to always return :ok, so I can't signal an overflow this way. Some other things that came to my mind:

  • drop the messages (not great);
  • in the contrary to the recommendation, intentionally slow down handle_message by sleeping;
  • use QoS 1 and somehow not acknowledge message which I could not handle (I'm using QoS 0);
  • unsubscribe, using next_actions response from handle_message (how do I resubscribe later?)

I don't feel confident about any of the above ways. Is there another proper way to pause receiving messages? Thank you.

RKushnir avatar Feb 24 '23 11:02 RKushnir