Replies: 2 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
4 replies
-
Another problem is the accumulator I am using. The one in the example above is not working as expected, the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I started discussions in the past (#967, #711) asking how to cancel the upstream. I never got an answer, I only got a particular solution (cancel in case of error by throwing an exception). But a solution to cancel is needed outside of error cases.
The task
Pick a service instance to handle some task. Which means load from a configuration file the settings for multiple/all service instances, instantiate a REST client for each, then try them one-by-one:
My approach
I know that the
multi.select().first(Predicate)
operator forwards the items while the passed predicate returnstrue
and could be used to only send the first configuration downstream that qualifies for the task (avoiding the need to cancel from the downstream handler). However, my decision is more costly than a predicate (needs at least one network call). So I need to do the query (if a service instance can handle the workload) in the downstream handler.I use a
Multi
for a stream of service configs in a Quarkus project (as all service configurations are loaded at once with a class that maps the YAML config file). Thus I will have to decide in the downstream handler when to stop.My sample implementation uses a REST client for Postman
GET /echo
to simulate the query to the service, asking if it can do the work (see repo https://github.com/thebe14/async-test).The problem
I do not know how to cancel the upstream from a downstream handler. Help!
Beta Was this translation helpful? Give feedback.
All reactions