Smart-cancellation between competing consumers #2758
-
We have the following article of the official documentation mentioning competing consumers (subscribers): https://docs.nats.io/nats-concepts/core-nats/reqreply Let's assume that after we distribute a task to these consumers, one of the consumers takes (say) 100ms to return a reply, while the rest take 500ms. Is Nats smart enough to somehow automatically communicate with the slow consumers and tell them to stop trying past the 100ms mark? And if so how does Nats do that? Does it set some kind of golang-context to "cancelled"? I'm asking because if one of the consumers has indeed completed the task within 100ms, the rest can simply stop working on the task - there is no point for them to continue working on it anymore. PS: If this type of feature is not provided out of the box I guess one would have to implement it "by hand" and send some kind of custom nats message to the consumers right after receiving the first response from the fastest consumer - it works but its a lot of error-prone hassle. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There is no automatic cancellation, but as you point out this can be handled for your specific solution in app. |
Beta Was this translation helpful? Give feedback.
There is no automatic cancellation, but as you point out this can be handled for your specific solution in app.