Interface ProcessingLifecycle
- All Known Subinterfaces:
ProcessingContext
- All Known Implementing Classes:
LegacyMessageSupportingContext,ResourceOverridingProcessingContext,UnitOfWork
default phases are defined that are used throughout the framework for these actions. The
ProcessingLifecycle has shorthand operations corresponding to these DefaultPhases. For example, the
onPreInvocation(Function) uses the ProcessingLifecycle.DefaultPhases.PRE_INVOCATION phase.
When the ProcessingLifecycle is started, the phases are invoked beginning
with the lowest ProcessingLifecycle.Phase.order(), moving up until all phase actions are executed. Note that actions registered
in a Phase with the same order may be executed in parallel.
If necessary, a custom ProcessingLifecycle.Phase can be defined that can be invoked before or after any other
Phase. To ensure it is invoked before/after one of the DefaultPhases, set the ProcessingLifecycle.Phase.order()
to a value higher/lower than the DefaultPhase you want the step to occur before or after.- Since:
- 5.0.0
- Author:
- Allard Buijze, Gerard Klijs, Milan Savić, Mitchell Herrijgers, Sara Pellegrini, Steven van Beelen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDefault phases used for the shorthand methods in theProcessingLifecycle.static interfaceFunctional interface describing an operation that's invoked when an error is detected within theProcessingLifecycle.static interfaceInterface describing a possible phase for theProcessingLifecycleto perform steps in. -
Method Summary
Modifier and TypeMethodDescriptiondefault ProcessingLifecycledoFinally(Consumer<ProcessingContext> action) Registers the providedactionto be executedon errorof andwhen completingthisProcessingLifecycle.booleanbooleanbooleanisError()booleanon(ProcessingLifecycle.Phase phase, Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in the givenphase.default ProcessingLifecycleonAfterCommit(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theafter commit phase.default ProcessingLifecycleonCommit(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thecommit phase.Registers the providedactionto be executed when thisProcessingLifecycleencounters an error during the action of anyProcessingLifecycle.Phase.default ProcessingLifecycleonInvocation(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theinvocation phase.default ProcessingLifecycleonPostInvocation(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thepost invocation phase.default ProcessingLifecycleonPreInvocation(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thepre-invocation phase.default ProcessingLifecycleonPrepareCommit(Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theprepare commit phase.default ProcessingLifecyclerunOn(ProcessingLifecycle.Phase phase, Consumer<ProcessingContext> action) Registers the providedactionto be executed in the givenphase.default ProcessingLifecyclerunOnAfterCommit(Consumer<ProcessingContext> action) Registers the providedactionto be executed in theafter commit phase.default ProcessingLifecyclerunOnCommit(Consumer<ProcessingContext> action) Registers the providedactionto be executed in thecommit phase.default ProcessingLifecyclerunOnInvocation(Consumer<ProcessingContext> action) Registers the providedactionto be executed in theinvocation phase.default ProcessingLifecyclerunOnPostInvocation(Consumer<ProcessingContext> action) Registers the providedactionto be executed in thepost invocation phase.default ProcessingLifecyclerunOnPreInvocation(Consumer<ProcessingContext> action) Registers the providedactionto be executed in thepre-invocation phase.default ProcessingLifecyclerunOnPrepareCommit(Consumer<ProcessingContext> action) Registers the providedactionto be executed in theprepare commit phase.whenComplete(Consumer<ProcessingContext> action) Registers the providedactionto be executed when thisProcessingLifecyclecompletes all registered actions.
-
Method Details
-
isStarted
boolean isStarted()- Returns:
truewhen thisProcessingLifecycleis started,falseotherwise.
-
isError
boolean isError()Returnstruewhen thisProcessingLifecycleis in error,falseotherwise.When
true, theregistered ErrorHandlerswill be invoked.- Returns:
truewhen thisProcessingLifecycleis in error,falseotherwise.
-
isCommitted
boolean isCommitted()- Returns:
truewhen thisProcessingLifecycleis committed,falseotherwise.
-
isCompleted
boolean isCompleted()Returnstruewhen thisProcessingLifecycleis completed,falseotherwise.Note that this
ProcessingLifecycleis marked as completed for a successful and failed completion.- Returns:
truewhen thisProcessingLifecycleis completed,falseotherwise.
-
on
ProcessingLifecycle on(@Nonnull ProcessingLifecycle.Phase phase, @Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in the givenphase. Uses theCompletableFuturereturned by theactionto compose actions and to carry the action's result.Use this operation when the return value of the
actionis important.- Parameters:
phase- TheProcessingLifecycle.Phaseto execute the givenactionin.action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOn
default ProcessingLifecycle runOn(@Nonnull ProcessingLifecycle.Phase phase, @Nonnull Consumer<ProcessingContext> action) Registers the providedactionto be executed in the givenphase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
phase- TheProcessingLifecycle.Phaseto execute the givenactionin.action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onPreInvocation
default ProcessingLifecycle onPreInvocation(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thepre-invocation phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnPreInvocation
Registers the providedactionto be executed in thepre-invocation phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onInvocation
default ProcessingLifecycle onInvocation(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theinvocation phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnInvocation
Registers the providedactionto be executed in theinvocation phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onPostInvocation
default ProcessingLifecycle onPostInvocation(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thepost invocation phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnPostInvocation
Registers the providedactionto be executed in thepost invocation phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onPrepareCommit
default ProcessingLifecycle onPrepareCommit(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theprepare commit phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnPrepareCommit
Registers the providedactionto be executed in theprepare commit phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onCommit
default ProcessingLifecycle onCommit(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in thecommit phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnCommit
Registers the providedactionto be executed in thecommit phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onAfterCommit
default ProcessingLifecycle onAfterCommit(@Nonnull Function<ProcessingContext, CompletableFuture<?>> action) Registers the providedactionto be executed in theafter commit phase.Use this operation when the return value of the
actionis important.- Parameters:
action- TheFunctionthat's given the activeProcessingContextand returns aCompletableFuturefor chaining purposes and to carry the action's result.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
runOnAfterCommit
Registers the providedactionto be executed in theafter commit phase.Use this operation when there is no need for a return value of the registered
action.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
onError
Registers the providedactionto be executed when thisProcessingLifecycleencounters an error during the action of anyProcessingLifecycle.Phase. This includes failures from actions registered throughwhenComplete(Consumer).When the given
ErrorHandlersare invokedisError()andisCompleted()will returntrue.- Parameters:
action- The error handler to execute when thisProcessingLifecycleencounters an error during phase execution.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
whenComplete
Registers the providedactionto be executed when thisProcessingLifecyclecompletes all registered actions.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-
doFinally
Registers the providedactionto be executedon errorof andwhen completingthisProcessingLifecycle.Note that if the given
actionthrows an exception when completing thisProcessingLifecycleit will be invoked again as an onProcessingLifecycle.ErrorHandler.- Parameters:
action- AConsumerthat's given the activeProcessingContextto perform its action.- Returns:
- This
ProcessingLifecycleinstance for fluent interfacing.
-