Class EventSourcedWorkflowState
- All Implemented Interfaces:
WorkflowState,DescribableComponent
evolve(org.axonframework.messaging.eventhandling.EventMessage, org.axonframework.messaging.core.unitofwork.ProcessingContext) method receiving messages.- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TypeReference<Map<String, @Nullable Object>> Type reference for a map of strings to objects used as workflow payload. -
Constructor Summary
ConstructorsConstructorDescriptionEventSourcedWorkflowState(String workflowId, Map<String, @Nullable Object> payload, VersionedType workflowDefinition) Creates a new workflow state without reference to a workflow context.EventSourcedWorkflowState(String workflowId, VersionedType workflowDefinition) Creates a new workflow state without reference to a workflow context and with an empty initial payload. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsStep(String stepName) Checks if a step with the given name exists in the workflow execution.static EventCriteriacriteriaBuilder(String workflowId) Criteria selecting all workflow-owned events for a single workflow identifier.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.evolve(EventMessage eventMessage, ProcessingContext processingContext) Applies an event while notifying workflow status listeners.@Nullable WorkflowStepRetrieves a step by name.booleanhasVersionMigrationStep(String changeId) Returnstrueiff a migration step has been projected into state for the givenchangeId.payload()Retrieves the payload of the workflow execution.static EventSourcedWorkflowStateReturns the event sourced workflow state.voidGuards against invoking any primitive when the workflow has already reached a terminal state.toString()versionFor(String changeId) Returns the effective version for the givenchangeId.Returns the recorded version migrations by change identifier.Returns the workflow definition identity, including its current definition version.Returns the unique workflow execution identifier.Returns the status of the workflow execution.Retrieves a list of step names in the workflow execution.
-
Field Details
-
PAYLOAD_TYPE
Type reference for a map of strings to objects used as workflow payload.
-
-
Constructor Details
-
EventSourcedWorkflowState
Creates a new workflow state without reference to a workflow context and with an empty initial payload.- Parameters:
workflowId- workflow id of the workflow executionworkflowDefinition- workflow definition representing the reference to the definition (name and version)
-
EventSourcedWorkflowState
@Internal public EventSourcedWorkflowState(String workflowId, Map<String, @Nullable Object> payload, VersionedType workflowDefinition) Creates a new workflow state without reference to a workflow context.- Parameters:
workflowId- workflow id of the workflow executionpayload- initial workflow payloadworkflowDefinition- workflow definition representing the reference to the definition (name and version)
-
-
Method Details
-
requireEventSourcedState
Returns the event sourced workflow state.- Parameters:
state- workflow state- Returns:
- event sourced workflow state or throws an exception if the given state is not an event sourced state
- Throws:
IllegalArgumentException- if the given state is not an event sourced state
-
criteriaBuilder
Criteria selecting all workflow-owned events for a single workflow identifier.- Parameters:
workflowId- workflow identifier- Returns:
- event criteria for workflow-state reconstruction
-
workflowId
Description copied from interface:WorkflowStateReturns the unique workflow execution identifier.- Specified by:
workflowIdin interfaceWorkflowState- Returns:
- workflow identifier
-
getStep
Description copied from interface:WorkflowStateRetrieves a step by name.- Specified by:
getStepin interfaceWorkflowState- Parameters:
stepName- name of the step- Returns:
- workflow step
-
containsStep
Description copied from interface:WorkflowStateChecks if a step with the given name exists in the workflow execution.- Specified by:
containsStepin interfaceWorkflowState- Parameters:
stepName- name of the step- Returns:
- true if the step exists, false otherwise
-
versionFor
Description copied from interface:WorkflowStateReturns the effective version for the givenchangeId.The effective version is the recorded version-migration string when a migration step has been projected for the change. Otherwise, it is
WorkflowState.workflowDefinitionId()'s version. This fallback is implicit, so workflows that have never executed actx.migrateVersion(changeId, newVersion)call carry no version-migration step in their event history.- Specified by:
versionForin interfaceWorkflowState- Parameters:
changeId- the change identifier to query- Returns:
- effective version for the change
-
hasVersionMigrationStep
Description copied from interface:WorkflowStateReturnstrueiff a migration step has been projected into state for the givenchangeId.Used by the migration primitive to distinguish "no recorded step, using the definition identity's version" from "an explicit migration step at the effective version". Only the former permits a new step to be written for a different version number.
- Specified by:
hasVersionMigrationStepin interfaceWorkflowState- Parameters:
changeId- the change identifier to query- Returns:
trueiff a migration step was recorded for thischangeId
-
versionMigrations
Description copied from interface:WorkflowStateReturns the recorded version migrations by change identifier.- Specified by:
versionMigrationsin interfaceWorkflowState- Returns:
- immutable map of recorded version migrations
-
workflowDefinitionId
Description copied from interface:WorkflowStateReturns the workflow definition identity, including its current definition version.Use
VersionedType.version()to obtain the definition version.- Specified by:
workflowDefinitionIdin interfaceWorkflowState- Returns:
- workflow definition identity
-
workflowStatus
Description copied from interface:WorkflowStateReturns the status of the workflow execution.- Specified by:
workflowStatusin interfaceWorkflowState- Returns:
- workflow status
-
workflowStepNames
Description copied from interface:WorkflowStateRetrieves a list of step names in the workflow execution.- Specified by:
workflowStepNamesin interfaceWorkflowState- Returns:
- list of step names
-
payload
Description copied from interface:WorkflowStateRetrieves the payload of the workflow execution.- Specified by:
payloadin interfaceWorkflowState- Returns:
- payload of the workflow execution
-
evolve
Applies an event while notifying workflow status listeners.- Parameters:
eventMessage- event message applied to the workflow stateprocessingContext- context in which the event is applied- Returns:
- this evolved workflow state
-
throwTerminalCause
public void throwTerminalCause()Description copied from interface:WorkflowStateGuards against invoking any primitive when the workflow has already reached a terminal state. Rethrows the original termination cause wrapped in the appropriate exception type.- Specified by:
throwTerminalCausein interfaceWorkflowState
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-
toString
-