Interface RouterCompletionCallback

All Superinterfaces:
CompletionCallback<Object,Object>

@NoImplement @MinMuleVersion("4.5.0") @Deprecated public interface RouterCompletionCallback extends CompletionCallback<Object,Object>
Deprecated.
since 0.9.0. Starting with Mule 4.7, routers can now have random outputs, use CompletionCallback instead
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:

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