tortoise
tortoise copied to clipboard
How to provide backpressure when too many incoming messages?
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 fromhandle_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.