Interface WorkflowConfigurationRegistry<W extends WorkflowConfigurationRegistry<W>>
- Type Parameters:
W- type of the registry.
- All Superinterfaces:
DescribableComponent
- All Known Implementing Classes:
SimpleWorkflowConfigurationRegistry
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic final classHolder for the SLF4J logger used by routing decisions (interfaces cannot have static loggers directly). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Context.ResourceKey<WorkflowConfigurationRegistry<?>> Resource key under which the owningWorkflowModule's own registry is stashed on a workflow execution'sProcessingContext. -
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<WorkflowConfiguration<?>> findByWorkflowNameAndVersion(String workflowName, String version) Finds a registered configuration byworkflowName+versionacross all qualified names.default Optional<WorkflowConfiguration<?>> findClosestHigherRegisteredVersion(String workflowName, String version) Finds the "next higher" routing match forworkflowName+version: the registered configuration whoseworkflowVersion()is the lowest version strictly greater than the requestedversion(semver-ordered).default Optional<WorkflowConfiguration<?>> findClosestRegisteredVersion(String workflowName, String version) Finds the "best routing match" for a givenworkflowName+version: the registered configuration whoseworkflowVersion()is the highest version less than or equal to the requestedversion(semver-ordered).default Optional<WorkflowConfiguration<?>> getByVersion(QualifiedName qualifiedName, String version) Returns the configuration registered forqualifiedNamewhoseWorkflowConfiguration.workflowVersion()equalsversion(semver-equal).Returns the configurations registered for the given eventtypewhoseWorkflowConfiguration.workflowVersion()is the highest among all registrations (semver-ordered).getHighestVersionConfigurations(QualifiedName qualifiedName) Returns the configurations registered forqualifiedNamewhoseWorkflowConfiguration.workflowVersion()is the highest among all registrations (semver-ordered).default Optional<WorkflowConfiguration<?>> getWorkflowConfiguration(VersionedType workflowDefinitionId) Finds a registered configuration by workflow definition reference.getWorkflowsConfigurations(QualifiedName qualifiedName) register(EventCondition eventCondition, WorkflowConfiguration<?> workflowConfiguration) default Wregister(QualifiedName qualifiedName, WorkflowConfiguration<?> workflowConfiguration) registeredVersions(String workflowName) Returns all workflow versions registered underworkflowNamein semver ascending order.default WorkflowConfiguration<?> resolveDefinitionForReplay(String workflowName, String workflowId, String stateVersion, WorkflowConfiguration<?> startConfig) Resolves whichWorkflowConfigurationshould drive an in-flight workflow's body, picking the definition that matches the version recorded in state.static WorkflowConfiguration<?> resolveOrFallback(ProcessingContext ctx, String workflowName, String workflowId, String stateVersion, WorkflowConfiguration<?> startConfig) Convenience helper that resolves theWorkflowConfigurationfor an in-flight workflow's body against the registry stashed on the givenProcessingContext(seeRESOURCE_KEY).default voidEmits a single startup warning per qualified name when multiple workflow definitions are registered at the same highest version.Methods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Field Details
-
RESOURCE_KEY
Resource key under which the owningWorkflowModule's own registry is stashed on a workflow execution'sProcessingContext.The registry is a per-module, named
Configurationcomponent (so severalWorkflowModules never share or collide over one), so it cannot be found through an unqualifiedConfigurationlookup. TheWorkflowEnginethat resolved it puts it here, once, at workflow-context creation time, soresolveOrFallback(org.axonframework.messaging.core.unitofwork.ProcessingContext, java.lang.String, java.lang.String, java.lang.String, io.axoniq.framework.workflow.runtime.api.execution.context.WorkflowConfiguration<?>)can read it back without knowing that name.
-
-
Method Details
-
resolveOrFallback
static WorkflowConfiguration<?> resolveOrFallback(ProcessingContext ctx, String workflowName, String workflowId, String stateVersion, WorkflowConfiguration<?> startConfig) Convenience helper that resolves theWorkflowConfigurationfor an in-flight workflow's body against the registry stashed on the givenProcessingContext(seeRESOURCE_KEY). When the registry is unavailable (e.g. tests that wire the execution directly without one), logs a[registry-missing]routing line and falls back tostartConfig. -
register
-
register
-
supportedEvents
Set<QualifiedName> supportedEvents() -
getWorkflowsConfigurations
List<WorkflowConfigurationRegistry.PredicatedWorkflowConfiguration> getWorkflowsConfigurations(QualifiedName qualifiedName) -
getHighestVersionConfigurations
default List<WorkflowConfigurationRegistry.PredicatedWorkflowConfiguration> getHighestVersionConfigurations(MessageType type) Returns the configurations registered for the given eventtypewhoseWorkflowConfiguration.workflowVersion()is the highest among all registrations (semver-ordered). Multiple configurations may be returned if duplicates exist at that version (run-in-parallel semantics).This is the lookup event-driven callers use, so the event's type reaches the registry whole. It is currently decided on
MessageType.qualifiedName()alone, and taking the full type keepsMessageType.version()in reach for when it participates in the decision. -
getHighestVersionConfigurations
default List<WorkflowConfigurationRegistry.PredicatedWorkflowConfiguration> getHighestVersionConfigurations(QualifiedName qualifiedName) Returns the configurations registered forqualifiedNamewhoseWorkflowConfiguration.workflowVersion()is the highest among all registrations (semver-ordered). Multiple configurations may be returned if duplicates exist at that version (run-in-parallel semantics).Event-driven callers should use
getHighestVersionConfigurations(MessageType); this variant serves registration-time recomputation, where only aQualifiedNameexists. -
getByVersion
default Optional<WorkflowConfiguration<?>> getByVersion(QualifiedName qualifiedName, String version) Returns the configuration registered forqualifiedNamewhoseWorkflowConfiguration.workflowVersion()equalsversion(semver-equal). If multiple are registered at that version, returns the first. -
findByWorkflowNameAndVersion
default Optional<WorkflowConfiguration<?>> findByWorkflowNameAndVersion(String workflowName, String version) Finds a registered configuration byworkflowName+versionacross all qualified names. Used to route an in-flight workflow's execution to the definition matching the version it was started under (as read from state, which sourced it from the started event'sMessageType.version()).- Parameters:
workflowName- name of the workflow (matchesWorkflowConfiguration.workflowName()).version- semver version string to match againstWorkflowConfiguration.workflowVersion().- Returns:
- matching configuration, or empty if none registered.
-
getWorkflowConfiguration
default Optional<WorkflowConfiguration<?>> getWorkflowConfiguration(VersionedType workflowDefinitionId) Finds a registered configuration by workflow definition reference.- Parameters:
workflowDefinitionId- workflow definition reference to resolve- Returns:
- matching configuration, or empty if none registered
-
findClosestRegisteredVersion
default Optional<WorkflowConfiguration<?>> findClosestRegisteredVersion(String workflowName, String version) Finds the "best routing match" for a givenworkflowName+version: the registered configuration whoseworkflowVersion()is the highest version less than or equal to the requestedversion(semver-ordered). Used to dispatch a workflow whose state version was bumped mid-flight viactx.migrateVersion(...)to a value that no exact sibling is registered for - e.g. v1.0.0 + v2.0.0 registered, state recorded "1.0.1", we want to route to the v1.0.0 definition, not jump to v2.0.0.Returns empty when no registered version is
<=the requested one (the workflow's recorded version is older than anything currently registered).- Parameters:
workflowName- name of the workflow.version- semver state version to route against.- Returns:
- the closest matching configuration, or empty if none qualifies.
-
findClosestHigherRegisteredVersion
default Optional<WorkflowConfiguration<?>> findClosestHigherRegisteredVersion(String workflowName, String version) Finds the "next higher" routing match forworkflowName+version: the registered configuration whoseworkflowVersion()is the lowest version strictly greater than the requestedversion(semver-ordered). Used to route an in-flight workflow forward to a newer definition when the developer bumped@Workflow(workflowVersion=...)past the version recorded in the workflow's state - e.g. instances started at "0.0.1" before the annotation was bumped to "0.0.2" must still find a body to replay against.Returns empty when no registered version is
>the requested one.- Parameters:
workflowName- name of the workflow.version- semver state version to route against.- Returns:
- the closest matching higher configuration, or empty if none qualifies.
-
warnAboutSameVersionDuplicates
default void warnAboutSameVersionDuplicates()Emits a single startup warning per qualified name when multiple workflow definitions are registered at the same highest version. Same-version duplicates run in parallel only if theirworkflowIdProviders produce distinct ids; otherwise the second start is rejected as a duplicate. Intended to be called once when the engine transitions to live mode. -
registeredVersions
Returns all workflow versions registered underworkflowNamein semver ascending order. Used for routing-decision logs. -
resolveDefinitionForReplay
default WorkflowConfiguration<?> resolveDefinitionForReplay(String workflowName, String workflowId, String stateVersion, WorkflowConfiguration<?> startConfig) Resolves whichWorkflowConfigurationshould drive an in-flight workflow's body, picking the definition that matches the version recorded in state. Five-pass routing:exact-match-start-config- start config matches state version.exact-match-sibling- registry has a sibling at the exact state version.closest-sibling- highest registered version ≤ state (covers mid-flightctx.migrateVersion()bumps to a value not statically registered).closest-higher-sibling- lowest registered version > state (covers the case where@Workflow(workflowVersion=...)has been bumped past the version recorded on the workflow's started event; in-flight instances still find a body to replay).no-match-fallback- nothing registered for this workflow name. WARN + start config; the drift safety net pauses if step names diverge.
-