Interface WorkflowModule<C extends WorkflowContext>
- Type Parameters:
C- the type ofWorkflowContextused by this workflowModule
- All Superinterfaces:
Module
- All Known Subinterfaces:
WorkflowModule.OptionalPhase<C>
Module that encapsulates the configuration for one or more workflow definitions, all sharing the
same WorkflowContext type defined by the generic C.
When constructed, the module registers its workflow configurations in the WorkflowConfigurationRegistry,
which in turn is used by the WorkflowEngine to
manage and execute workflows.
Default configuration
Modules created throughdefaults(String, Class) use sensible defaults for infrastructure components (such as
the WorkflowConfigurationRegistry, WorkflowExecutionRepository, and history). This is the recommended
entry point for most use cases. A WorkflowContextFactory has no generic default of its own, but a DSL module
(such as axoniq-workflow-dsl or its Kotlin counterpart) registers one automatically for its own
WorkflowContext type, so a custom contextType() is typically the only case still requiring an
explicit WorkflowModule.OptionalPhase.contextFactory(ComponentBuilder).
Custom configuration
configure(String, Class) is, for now, equivalent to defaults(String, Class): every infrastructure
setting - the event processor, history tracking, the registry, and the repository - has moved into the terminal
WorkflowModule.OptionalPhase, so there is no longer a distinct pre-definition configuration phase between the two entry
points.
Workflow language
The language phase defines one or more workflow definitions:WorkflowModule.WorkflowDefinitionPhase- define one or more workflow definitions, eitherdeclarativelyorautodetected.
Terminal configuration
Once the workflow definitions are in place,WorkflowModule.OptionalPhase allows the PooledStreamingEventProcessorConfiguration
backing the module's event processor to be customized, workflow history tracking to be enabled or disabled, and a
custom WorkflowContextFactory, WorkflowConfigurationRegistry, and/or WorkflowExecutionRepository
to be supplied. Reaching this phase already yields a fully-formed WorkflowModule: every method here is
optional, each falling back to a working default when left uncalled - for
WorkflowModule.OptionalPhase.contextFactory(ComponentBuilder), that default is whatever a DSL module registered for
contextType(), which only a custom WorkflowContext type lacks.
Autodetected workflows
Workflows can be built usingWorkflowModule.WorkflowDefinitionPhase.DetectionPhase.autodetected(ComponentBuilder), which
inspects the given component for workflow annotations and automatically derives the workflow definition.
Declarative workflows
Alternatively,WorkflowModule.WorkflowDefinitionPhase.DetectionPhase.declarative(ComponentBuilder) allows manual
construction of the workflow through a series of builder phases: naming,
trigger definition, and
customization.- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceWorkflowModule.OptionalPhase<C extends WorkflowContext>Terminal phase of the module's building process, in which a multitude of optional components can be set:WorkflowModule.OptionalPhase.definition(Function)- add another workflow definition to this module.WorkflowModule.OptionalPhase.processorConfiguration(Function)- customize thePooledStreamingEventProcessorConfigurationbacking this module's event processor.WorkflowModule.OptionalPhase.withHistory(ComponentBuilder)/WorkflowModule.OptionalPhase.withoutHistory()- enable or disable workflow history tracking.WorkflowModule.OptionalPhase.historyProcessorConfiguration(Function)- customize thePooledStreamingEventProcessorConfigurationbacking the history projector's own event processor.WorkflowModule.OptionalPhase.contextFactory(ComponentBuilder)- override theWorkflowContextFactoryused to create theWorkflowContextfor each workflow execution.WorkflowModule.OptionalPhase.configurationRegistry(ComponentBuilder)- override theWorkflowConfigurationRegistrystoring workflow configurations and their start conditions.WorkflowModule.OptionalPhase.executionRepository(ComponentBuilder)- override theWorkflowExecutionRepositorypersisting and retrieving workflow instances.static interfacePhase of the module's building process in which one or more workflow definitions are provided. -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends WorkflowContext>
WorkflowModule.WorkflowDefinitionPhase<C> Creates a new workflow module, exposing the sameWorkflowModule.WorkflowDefinitionPhaseentry point asdefaults(String, Class).Returns theWorkflowContexttype used by the workflows configured in this module.static <C extends WorkflowContext>
WorkflowModule.WorkflowDefinitionPhase<C> Creates a new workflow module using default infrastructure settings, the recommended entry point for most use cases.
-
Method Details
-
defaults
static <C extends WorkflowContext> WorkflowModule.WorkflowDefinitionPhase<C> defaults(String name, Class<C> contextType) Creates a new workflow module using default infrastructure settings, the recommended entry point for most use cases.Note that the given
contextTypeis expected to be one originating from this project. If a customcontextTypeis given, be sure to set thecontext factoryfor it as well.- Type Parameters:
C- the type ofWorkflowContextused by the workflows in this module- Parameters:
name- name of the workflow modulecontextType- theWorkflowContexttype used by the workflows in this module- Returns:
- the
WorkflowModule.WorkflowDefinitionPhasephase of this builder, for a fluent API
-
configure
static <C extends WorkflowContext> WorkflowModule.WorkflowDefinitionPhase<C> configure(String name, Class<C> contextType) Creates a new workflow module, exposing the sameWorkflowModule.WorkflowDefinitionPhaseentry point asdefaults(String, Class).The
PooledStreamingEventProcessorConfigurationbacking the module's event processor, history tracking, theWorkflowConfigurationRegistry, theWorkflowExecutionRepository, and theWorkflowContextFactoryare all configured after the workflow definitions, through the terminalWorkflowModule.OptionalPhase.Note that if the given
contextTypeis not one originating from this project, that a customcontext factoryshould be configured at all times.- Type Parameters:
C- the type ofWorkflowContextused by the workflows in this module- Parameters:
name- name of the workflow modulecontextType- theWorkflowContexttype used by the workflows in this module- Returns:
- the
WorkflowModule.WorkflowDefinitionPhasephase of this builder, for a fluent API
-
contextType
Returns theWorkflowContexttype used by the workflows configured in this module.- Returns:
- the
WorkflowContexttype of this module
-