Class WorkflowRuntimeBuilder
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs the WorkflowRuntimeBuilder.WorkflowRuntimeBuilder(Properties properties) Constructs the WorkflowRuntimeBuilder.WorkflowRuntimeBuilder(org.slf4j.Logger logger) -
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns a WorkflowRuntime object.<T extends WorkflowActivity>
WorkflowRuntimeBuilderregisterActivity(Class<T> clazz) Registers an Activity object.<T extends WorkflowActivity>
WorkflowRuntimeBuilderregisterActivity(String name, Class<T> clazz) Registers an Activity object.<T extends WorkflowActivity>
WorkflowRuntimeBuilderregisterActivity(String name, T instance) Registers an Activity object.<T extends WorkflowActivity>
WorkflowRuntimeBuilderregisterActivity(T instance) Registers an Activity object.registerTaskActivityFactory(String activityName, TaskActivityFactory taskActivityFactory) Registers a Task Activity using aTaskActivityFactory.registerTaskOrchestrationFactory(String orchestrationName, TaskOrchestrationFactory taskOrchestrationFactory) Registers a Task Orchestration using aTaskOrchestrationFactory.<T extends Workflow>
WorkflowRuntimeBuilderregisterWorkflow(Class<T> clazz) Registers a Workflow object.<T extends Workflow>
WorkflowRuntimeBuilderregisterWorkflow(String name, Class<T> clazz) Registers a Workflow object.<T extends Workflow>
WorkflowRuntimeBuilderregisterWorkflow(String name, Class<T> clazz, String versionName, Boolean isLatestVersion) Registers a Workflow object.<T extends Workflow>
WorkflowRuntimeBuilderregisterWorkflow(String name, T instance, String versionName, Boolean isLatestVersion) Registers a Workflow object.<T extends Workflow>
WorkflowRuntimeBuilderregisterWorkflow(T instance) Registers a Workflow object.withExecutorService(ExecutorService executorService) Register Executor Service to use with workflow.withHistoryCacheMaxBytes(long historyCacheMaxBytes) Sets the byte budget for cached histories on a single work-item stream; least-recently-used entries are evicted beyond it.withHistoryCacheMaxInstances(int historyCacheMaxInstances) Sets the maximum number of per-instance histories retained on a single work-item stream; least-recently-used entries are evicted beyond it.withHistoryCacheTtl(Duration historyCacheTtl) Sets the sliding time-to-live for cached instance histories.withStatefulHistoryDisabled(boolean disableStatefulHistory) Disables the stateful-history optimization.
-
Constructor Details
-
WorkflowRuntimeBuilder
public WorkflowRuntimeBuilder()Constructs the WorkflowRuntimeBuilder. -
WorkflowRuntimeBuilder
Constructs the WorkflowRuntimeBuilder.- Parameters:
properties- Properties to use.
-
WorkflowRuntimeBuilder
public WorkflowRuntimeBuilder(org.slf4j.Logger logger)
-
-
Method Details
-
build
Returns a WorkflowRuntime object.The runtime is shared: while one is open, every call returns that same instance. Once it has been
closed, the next call builds a new runtime, which allows a full restart (for example on a live reload or between tests). Closing a runtime also shuts down the channel of the builder that created it, so the new runtime must be built from a new builder.- Returns:
- A WorkflowRuntime object.
- Throws:
IllegalStateException- if a new runtime is needed but this builder's channel has already been shut down by a previous runtime.
-
withExecutorService
Register Executor Service to use with workflow.- Parameters:
executorService- to be used.- Returns:
WorkflowRuntimeBuilder.
-
withStatefulHistoryDisabled
Disables the stateful-history optimization.By default the worker advertises
WORKER_CAPABILITY_STATEFUL_HISTORYand caches each instance's committed history per work-item stream, so the sidecar can send only the new events (the delta) each turn instead of the full history. A cache miss is always recovered safely via the GetInstanceHistory RPC, so disabling this only affects per-turn bandwidth, never correctness. When disabled, the worker always receives the full history.- Parameters:
disableStatefulHistory- whether to disable the stateful-history optimization- Returns:
WorkflowRuntimeBuilder.
-
withHistoryCacheTtl
Sets the sliding time-to-live for cached instance histories. An instance's entry is reclaimed once it has gone idle (no turn) for longer than this. If not specified, a default of one hour is used. Ignored when the stateful-history optimization is disabled.- Parameters:
historyCacheTtl- the sliding time-to-live for a cached instance history- Returns:
WorkflowRuntimeBuilder.
-
withHistoryCacheMaxInstances
Sets the maximum number of per-instance histories retained on a single work-item stream; least-recently-used entries are evicted beyond it. A non-positive value uses the built-in default. Ignored when the stateful-history optimization is disabled.- Parameters:
historyCacheMaxInstances- the instance-count cap for the history cache- Returns:
WorkflowRuntimeBuilder.
-
withHistoryCacheMaxBytes
Sets the byte budget for cached histories on a single work-item stream; least-recently-used entries are evicted beyond it. A non-positive value means unlimited (bounded only by the instance-count cap and the TTL). Ignored when the stateful-history optimization is disabled.- Parameters:
historyCacheMaxBytes- the byte budget for the history cache- Returns:
WorkflowRuntimeBuilder.
-
registerWorkflow
Registers a Workflow object.- Type Parameters:
T- any Workflow type- Parameters:
clazz- the class being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerWorkflow
Registers a Workflow object.- Type Parameters:
T- any Workflow type- Parameters:
name- the name of the workflow to registerclazz- the class being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerWorkflow
public <T extends Workflow> WorkflowRuntimeBuilder registerWorkflow(String name, Class<T> clazz, String versionName, Boolean isLatestVersion) Registers a Workflow object.- Type Parameters:
T- any Workflow type- Parameters:
name- the name of the workflow to registerclazz- the class being registeredversionName- the version name of the workflowisLatestVersion- whether the workflow is the latest version- Returns:
- the WorkflowRuntimeBuilder
-
registerWorkflow
Registers a Workflow object.- Type Parameters:
T- any Workflow type- Parameters:
instance- the workflow instance being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerWorkflow
public <T extends Workflow> WorkflowRuntimeBuilder registerWorkflow(String name, T instance, String versionName, Boolean isLatestVersion) Registers a Workflow object.- Type Parameters:
T- any Workflow type- Parameters:
name- the name of the workflow to registerinstance- the workflow instance being registeredversionName- the version name of the workflowisLatestVersion- whether the workflow is the latest version- Returns:
- the WorkflowRuntimeBuilder
-
registerActivity
Registers an Activity object.- Type Parameters:
T- any WorkflowActivity type- Parameters:
clazz- the class being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerActivity
public <T extends WorkflowActivity> WorkflowRuntimeBuilder registerActivity(String name, Class<T> clazz) Registers an Activity object.- Type Parameters:
T- any WorkflowActivity type- Parameters:
name- Name of the activity to register.clazz- Class of the activity to register.- Returns:
- the WorkflowRuntimeBuilder
-
registerActivity
Registers an Activity object.- Type Parameters:
T- any WorkflowActivity type- Parameters:
instance- the class instance being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerActivity
public <T extends WorkflowActivity> WorkflowRuntimeBuilder registerActivity(String name, T instance) Registers an Activity object.- Type Parameters:
T- any WorkflowActivity type- Parameters:
name- Name of the activity to register.instance- the class instance being registered- Returns:
- the WorkflowRuntimeBuilder
-
registerTaskActivityFactory
public WorkflowRuntimeBuilder registerTaskActivityFactory(String activityName, TaskActivityFactory taskActivityFactory) Registers a Task Activity using aTaskActivityFactory.This method allows advanced use cases where activities are created dynamically or require custom instantiation logic instead of relying on class-based or instance-based registration.
- Parameters:
activityName- the logical name of the activity to registertaskActivityFactory- the factory responsible for creating the activity- Returns:
- the
WorkflowRuntimeBuilder
-
registerTaskOrchestrationFactory
public WorkflowRuntimeBuilder registerTaskOrchestrationFactory(String orchestrationName, TaskOrchestrationFactory taskOrchestrationFactory) Registers a Task Orchestration using aTaskOrchestrationFactory.This method is intended for advanced scenarios where orchestrations are created programmatically or require custom construction logic, rather than being registered via workflow classes or instances.
- Parameters:
orchestrationName- the logical name of the orchestration to registertaskOrchestrationFactory- the factory responsible for creating the orchestration- Returns:
- the
WorkflowRuntimeBuilder
-