@MinMuleVersion("4.1") @NoImplement public interface Chain
A Chain allows a given Operation to receive a chain of message processors to be executed as part of the operation's execution.

When executing the Chain, all its inner components will be executed in the order declared by the user, using the output of one processor as the input of the next one in the Chain. The execution of the Chain is completed either when all the components were invoked successfully or when an error occurs in one processor, and it is propagated to the Chain

Since:
1.0
  • Method Details

    • process

      void process(Consumer<Result> onSuccess, BiConsumer<Throwable,Result> onError)
      Executes the chain of components starting with the same input message that it's container scope received.

      onSuccess callback will be invoked with the output Result of the last component in the Chain if no error occurred after all the components were executed exactly once.

      onError callback will be invoked with the exception propagated by the first failing component, along with the last output Result available. The given Result will be the same that was used as input of the failing component.

      Parameters:
      onSuccess - the callback to be executed when a successful execution is completed by the Chain
      onError - the callback to be executed when an error occurs during the execution of the Chain components
    • process

      void process(Object payload, Object attributes, Consumer<Result> onSuccess, BiConsumer<Throwable,Result> onError)
      Executes the chain of components starting with the given payload and attributes as Message.

      onSuccess callback will be invoked with the output Result of the last component in the Chain if no error occurred after all the components were executed exactly once.

      onError callback will be invoked with the exception propagated by the first failing component, along with the last output Result available. The given Result will be the same that was used as input of the failing component.

      Parameters:
      onSuccess - the callback to be executed when a successful execution is completed by the Chain
      onError - the callback to be executed when an error occurs during the execution of the Chain components
    • process

      void process(Result input, Consumer<Result> onSuccess, BiConsumer<Throwable,Result> onError)
      Executes the chain of components starting with the given Result data as input Message. This method should be used whenever the input of this Chain is the output of another component execution.

      onSuccess callback will be invoked with the output Result of the last component in the Chain if no error occurred after all the components were executed exactly once.

      onError callback will be invoked with the exception propagated by the first failing component, along with the last output Result available. The given Result will be the same that was used as input of the failing component.

      Parameters:
      onSuccess - the callback to be executed when a successful execution is completed by the Chain
      onError - the callback to be executed when an error occurs during the execution of the Chain components