This callback is how Routers notify the end of its execution when no result is produced.
In order to implement a Void Router, the method needs to:
- Have a void return type
- Have at least one argument of
Routetype - Have an argument of
VoidCompletionCallbacktype
When the processing performed by the Router finishes, it has to notify its completion either by invoking the success()
or 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.
For example, a Void Router can be declared as:
public void enricher(WhenRoute when, @Optional DefaultRoute defaultRoute, VoidCompletionCallback callback) {
if (when.shouldExecute()) {
when.getChain().process(r -> callback.success(),
(e, r) -> callback.error(e));
} else if (other != null && other.shouldExecute()) {
other.getChain().process(r -> callback.success(),
(e, r) -> callback.error(e));
} else {
callback.error(new IllegalArgumentException("No route executed"));
}
}
As you can see, the result of the Route being executed is ignored, and the callback is notified
with a success() or error(Throwable)
- Since:
- 1.0
-
Method Summary
-
Method Details
-
success
void success()This method is to be invoked when the Router execution is completed successfully -
error
This method is to be invoked when the Router execution ends with an error.- Parameters:
e- the exception found
-