Interface WorkflowModule<C extends WorkflowContext>

Type Parameters:
C - the type of WorkflowContext used by this workflow Module
All Superinterfaces:
Module
All Known Subinterfaces:
WorkflowModule.OptionalPhase<C>

public interface WorkflowModule<C extends WorkflowContext> extends Module
A workflow 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 through defaults(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:

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 using WorkflowModule.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