Class MigrateSagaLifecycle
- All Implemented Interfaces:
Cloneable
SagaLifecycle access to the context-scoped Axon Framework 5 legacy API.
Every @SagaEventHandler that invokes SagaLifecycle.associateWith(...),
SagaLifecycle.removeAssociationWith(...), SagaLifecycle.end(), or
SagaLifecycle.associationValues() receives a SagaLifecycle method parameter. Calls are redirected
to that parameter. Axon Framework 5 injects the active Saga lifecycle into annotated handler parameters.
The legacy module injects that parameter into @SagaEventHandler methods only, so other Saga methods calling
the static SagaLifecycle need a different shape. A @DeadlineHandler whose only lifecycle call is a
closing SagaLifecycle.end() statement, and which has no return that could skip it, is annotated with
@EndSaga instead, which ends the Saga once the handler completes, exactly like that last statement did. Any
other @DeadlineHandler of a Saga, such as one with a conditional end, an end an early return can
skip, or an association change, receives a ProcessingContext parameter, and each static call becomes
SagaLifecycle.forContext(processingContext).<call>(..) in place. The Saga registers itself as the
SagaLifecycle of the context it handles a deadline in. A @DeadlineHandler without parameters first
gets a DeadlineMessage parameter, because the ProcessingContext resolver ranks below the payload
resolver and would otherwise turn that parameter into the payload. A static call in any other Saga method, such as a
private helper, is kept and marked with a // TODO(axon4to5): comment for a manual migration, as each of its
callers would have to pass the context on.
- Since:
- 5.4.0
- Author:
- Mateusz Nowak
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openrewrite.Recipe
org.openrewrite.Recipe.Builder, org.openrewrite.Recipe.DelegatingRecipe -
Field Summary
Fields inherited from class org.openrewrite.Recipe
contributors, examples, PANIC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.openrewrite.TreeVisitor<?, org.openrewrite.ExecutionContext> Methods inherited from class org.openrewrite.Recipe
addDataTable, aggregateDataTableDescriptors, builder, buildRecipeList, causesAnotherCycle, clone, createRecipeDescriptor, equals, getContributors, getDataTableDescriptors, getDescriptor, getEstimatedEffortPerOccurrence, getExamples, getInstanceName, getInstanceNameSuffix, getJacksonPolymorphicTypeTag, getMaintainers, getName, getRecipeList, getTags, hashCode, maxCycles, noop, onComplete, run, run, run, setContributors, setExamples, validate, validate, validateAll, validateAll, withOptions
-
Constructor Details
-
MigrateSagaLifecycle
public MigrateSagaLifecycle()
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
- Specified by:
getDescriptionin classorg.openrewrite.Recipe
-
getVisitor
public org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()- Overrides:
getVisitorin classorg.openrewrite.Recipe
-