- All Superinterfaces:
CompletionCallback<Object,Object>
@NoImplement
@MinMuleVersion("4.5.0")
@Deprecated
public interface RouterCompletionCallback
extends CompletionCallback<Object,Object>
Deprecated.
This callback is how a Router receiving
Routes notify their outcome.
In order to implement a Router (that is, an operation that receives one or more Routes), the method needs to:
- Have a void return type
- Have at least one argument of
Routetype - Have an argument of
RouterCompletionCallbacktype
When the execution of the Router has finished, it has to notify the Result either by invoking the
CompletionCallback.success(Result) or CompletionCallback.error(Throwable) methods. Only then will the execution of the Router be considered as
completed and the next processor in the pipeline will be executed. If the CompletionCallback.success(Result) or
CompletionCallback.error(Throwable) methods are invoked before any of the nested Routes is completed, the Result of the
nested execution will be lost and never propagated.
For example, a Router can be declared as:
public void twoRoutesRouter(WhenRoute when, @Optional OtherwiseRoute other, RouterCompletionCallback callback) {
if (when.shouldExecute()) {
when.getChain().process(routeResult -> callback.success(routeResult), (e, r) -> callback.error(e));
} else if (other != null && other.shouldExecute()) {
other.getChain().process(callback::success, (e, r) -> callback.error(e));
} else {
callback.error(new IllegalArgumentException("No route could be executed"));
}
}
- Since:
- 1.0
-
Method Summary
Methods inherited from interface org.mule.sdk.api.runtime.process.CompletionCallback
error, success
CompletionCallbackinstead