I am using spring cloud function chaining in my project like below:
spring.cloud.function.definition = func_A|func_B|func_C|func_D
The above definition will pipe the result of func_A
to func_B
, and from func_B
to func_C
and so on...
Now if I have a business logic in func_B
that requires to stop the propagation to the following functions (fun_C
and func_D
), how to do it? I know throwing an exception in func_B
will stop the propagation, but is there any graceful way other than throwing exception?
Basically I need something like this in code level:
if(true){
proceed to `func_C` and `func_D`
}else{
stop and return (without throwing exception)
(or) route to a consumer function (where I will just log a message)
}
Thanks in advance:)
The problem is in terminology. You are using the word "chaining", hence your question about propagation and so on. . . However. . . There is no "chaining". There is "composition" and result of a composition is a single function (as if you wrote everything yourself in a single function). So effectively you are asking how can you invoke a function without producing an output? That would simply not compile. So either throw an exception or you must return something.