Workflow abstract class is the base class for all workflow implementations in Infinitic. Workflows orchestrate the execution of tasks and other workflows in a durable, fault-tolerant manner.
Package
Overview
Workflows in Infinitic are defined by extending theWorkflow abstract class. The workflow implementation contains the orchestration logic that coordinates tasks, handles results, and manages the overall business process.
Static Properties
These properties provide context information about the currently executing workflow:The name of the workflow
The unique identifier of the workflow instance
The name of the currently executing workflow method
The unique identifier of the workflow method execution
The set of tags associated with the workflow instance
Metadata associated with the workflow instance
Protected Methods
Task and Workflow Creation
Creates a stub for dispatching tasks to a serviceParameters:
klass: Class<out T>- The service interface classtags: Set<String>?- Optional tags to apply to tasks (default: null)meta: Map<String, ByteArray>?- Optional metadata for tasks (default: null)
Creates a stub for dispatching a new child workflowParameters:
klass: Class<out T>- The workflow interface classtags: Set<String>?- Optional tags to apply to the workflow (default: null)meta: Map<String, ByteArray>?- Optional metadata for the workflow (default: null)
Gets a stub for an existing workflow by its IDParameters:
klass: Class<out T>- The workflow interface classid: String- The workflow instance ID
Gets a stub for an existing workflow by its tagParameters:
klass: Class<out T>- The workflow interface classtag: String- The workflow tag
Dispatching Tasks and Workflows
Dispatches a task or workflow method and returns a Deferred for the resultOverloads:
dispatch(method: () -> R): Deferred<R>- No parametersdispatch(method: (P1) -> R, p1: P1): Deferred<R>- 1 parameterdispatch(method: (P1, P2) -> R, p1: P1, p2: P2): Deferred<R>- 2 parameters- Up to 9 parameters supported
Dispatches a task or workflow method that returns voidOverloads: Support 0 to 9 parameters using Consumer interfaces
Timers
Creates a timer that completes after a specified duration or at a specific instantOverloads:
timer(duration: Duration): Deferred<Instant>- Timer based on durationtimer(instant: Instant): Deferred<Instant>- Timer based on absolute time
Channels
Creates a channel for sending and receiving signals within the workflowReturns: A new Channel instanceExample:
Inline Execution
Executes a task inline (synchronously) without dispatchingParameters:
task: () -> S- The task to execute
Executes a void task inline (synchronously) without dispatchingParameters:
task: Consumer0- The task to execute
Usage Example
Notes
- All workflow methods must be deterministic
- Use
@Ignoreannotation on properties that should not be persisted - Workflows are automatically retried on failure according to the retry policy
- Channel names are automatically set based on the getter method name
See Also
- Deferred - For handling asynchronous results
- InfiniticClient - For starting workflows
- Annotations - For configuring workflow behavior