Package io.nflow.engine.listener
Interface WorkflowExecutorListener
-
- All Known Implementing Classes:
WorkflowLogContextListener
public interface WorkflowExecutorListenerWorkflowExecutorListener is a global, stateless listener for workflow executors. The interface contains default (no-op) method implementations.Same instance of WorkflowExecutorListener is used for all workflow state executions: all state must be stored in
ListenerContext.data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWorkflowExecutorListener.ListenerContextListenerContext instance is created at start of workflow state execution and passed to listener's life-cycle methods.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidafterFailure(WorkflowExecutorListener.ListenerContext listenerContext, Throwable throwable)Executed after state processing has failed and before persisting state.default voidafterProcessing(WorkflowExecutorListener.ListenerContext listenerContext)Executed after state has been successfully processed and before persisting state.default voidbeforeProcessing(WorkflowExecutorListener.ListenerContext listenerContext)Executed before state is processed.default booleanhandlePotentiallyStuck(WorkflowExecutorListener.ListenerContext listenerContext, org.joda.time.Duration processingTime)Called when instance processing is potentially stuck.default NextActionprocess(WorkflowExecutorListener.ListenerContext listenerContext, ListenerChain chain)Processing chain.
-
-
-
Method Detail
-
beforeProcessing
default void beforeProcessing(WorkflowExecutorListener.ListenerContext listenerContext)
Executed before state is processed. Exceptions are logged but they do not affect workflow processing.- Parameters:
listenerContext- The listener context.
-
process
default NextAction process(WorkflowExecutorListener.ListenerContext listenerContext, ListenerChain chain)
Processing chain. Process methods in listeners form a Chain of Responsibility pattern. Listener can either call chain.next(listenerContext) to proceed to next filter or not to call it causing processing of state to be skipped. Changes to workflowInstance (not child workflows or state variables) by the filter will be persisted to database.Typical implementation:
public NextAction process(ListenerContext listenerContext, ListenerChain chain) { return chain.next(listenerContext); }- Parameters:
listenerContext- The listener context.chain- The listener chain.- Returns:
- NextAction
-
afterProcessing
default void afterProcessing(WorkflowExecutorListener.ListenerContext listenerContext)
Executed after state has been successfully processed and before persisting state. Exceptions are logged but they do not affect workflow processing.- Parameters:
listenerContext- The listener context.
-
afterFailure
default void afterFailure(WorkflowExecutorListener.ListenerContext listenerContext, Throwable throwable)
Executed after state processing has failed and before persisting state. Exceptions are logged but they do not affect workflow processing.- Parameters:
listenerContext- The listener context.throwable- The exception thrown by the state handler method.
-
handlePotentiallyStuck
default boolean handlePotentiallyStuck(WorkflowExecutorListener.ListenerContext listenerContext, org.joda.time.Duration processingTime)
Called when instance processing is potentially stuck. Return true to interrupt the processing thread. Default implementation returns false.- Parameters:
listenerContext- The listener context.processingTime- How long the instances has been processed.- Returns:
- True if processing should be interruped, false otherwise.
-
-