@MinMuleVersion(value="4.1")
@NoImplement
public interface FlowListener
extends org.mule.sdk.api.runtime.operation.FlowListener
Operation can declare an argument of this type and the runtime will automatically inject an implementation which the operation can use.
An example use case is an operation which needs to await for the owning flow to finish in order to execute some clean-up, or wants to know the final outcome in order to log it or audit it.
For example, let's see a very simple logging case
public void listeningOperation(FlowListener listener) {
listener.onSuccess(message -> LOGGER.debug("Response obtained", message.getPayload().getValue()));
listener.onError(exception -> LOGGER.debug("Flow failed", exception));
listener.onComplete(() -> doCleanUp());
}
}
Instances are not reusable and should not be cached. Instances are also not thread-safe. No instance should be used in a thread different from the one executing the operation.
Copyright © 2024 MuleSoft, Inc.. All rights reserved.