Class WorkflowOptions.Builder

java.lang.Object
io.temporal.client.WorkflowOptions.Builder
Enclosing class:
WorkflowOptions

public static final class WorkflowOptions.Builder extends Object
  • Method Details

    • setWorkflowId

      public WorkflowOptions.Builder setWorkflowId(String workflowId)
      Workflow id to use when starting. If not specified a UUID is generated. Note that it is dangerous as in case of client side retries no deduplication will happen based on the generated id. So prefer assigning business meaningful ids if possible.
    • setWorkflowIdReusePolicy

      public WorkflowOptions.Builder setWorkflowIdReusePolicy(io.temporal.api.enums.v1.WorkflowIdReusePolicy workflowIdReusePolicy)
      Specifies server behavior if a completed workflow with the same id exists. Note that under no conditions Temporal allows two workflows with the same namespace and workflow id run simultaneously. See setWorkflowIdConflictPolicy(io.temporal.api.enums.v1.WorkflowIdConflictPolicy) for handling a workflow id duplication with a Running workflow.

      Default value if not set: AllowDuplicate

      • AllowDuplicate allows a new run regardless of the previous run's final status. The previous run still must be closed or the new run will be rejected.
      • AllowDuplicateFailedOnly allows a new run if the previous run failed, was canceled, or terminated.
      • RejectDuplicate never allows a new run, regardless of the previous run's final status.
      • TerminateIfRunning is the same as AllowDuplicate, but if there exists a not-closed run in progress, it will be terminated.
    • setWorkflowIdConflictPolicy

      public WorkflowOptions.Builder setWorkflowIdConflictPolicy(io.temporal.api.enums.v1.WorkflowIdConflictPolicy workflowIdConflictPolicy)
      Specifies server behavior if a Running workflow with the same id exists. See setWorkflowIdReusePolicy(io.temporal.api.enums.v1.WorkflowIdReusePolicy) for handling a workflow id duplication with a Closed workflow. Cannot be set when WorkflowOptions.getWorkflowIdReusePolicy() is WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING.
      • Fail Don't start a new workflow; instead return WorkflowExecutionAlreadyStarted
      • UseExisting Don't start a new workflow; instead return the handle for the running workflow.
      • TerminateExisting Terminate the running workflow before starting a new one.
    • setWorkflowRunTimeout

      public WorkflowOptions.Builder setWorkflowRunTimeout(Duration workflowRunTimeout)
      The time after which a workflow run is automatically terminated by Temporal service with WORKFLOW_EXECUTION_TIMED_OUT status.

      When a workflow reaches Workflow Run Timeout, it can't make any progress after that. Do not rely on this timeout in workflow implementation or business logic. This timeout is not designed to be handled in workflow code to perform any logic in case of timeout. Consider using workflow timers instead.

      If you catch yourself setting this timeout to very small values, you're likely using it wrong.

      Example: If Workflow Run Timeout is 30 seconds and the network was unavailable for 1 minute, workflows that were scheduled before the network blip will never have a chance to make progress or react, and will be terminated.
      A timer that is scheduled in the workflow code using Workflow.newTimer(Duration) will handle this situation gracefully. A workflow with such a timer will start after the network blip. If it started before the network blip and the timer fires during the network blip, it will get delivered after connectivity is restored and the workflow will be able to resume.

    • setWorkflowExecutionTimeout

      public WorkflowOptions.Builder setWorkflowExecutionTimeout(Duration workflowExecutionTimeout)
      The time after which workflow execution (which includes run retries and continue as new) is automatically terminated by Temporal service with WORKFLOW_EXECUTION_TIMED_OUT status.

      When a workflow reaches Workflow Execution Timeout, it can't make any progress after that. Do not rely on this timeout in workflow implementation or business logic. This timeout is not designed to be handled in workflow code to perform any logic in case of timeout. Consider using workflow timers instead.

      If you catch yourself setting this timeout to very small values, you're likely using it wrong.

      Example: If Workflow Execution Timeout is 30 seconds and the network was unavailable for 1 minute, workflows that were scheduled before the network blip will never have a chance to make progress or react, and will be terminated.
      A timer that is scheduled in the workflow code using Workflow.newTimer(Duration) will handle this situation gracefully. A workflow with such a timer will start after the network blip. If it started before the network blip and the timer fires during the network blip, it will get delivered after connectivity is restored and the workflow will be able to resume.

    • setWorkflowTaskTimeout

      public WorkflowOptions.Builder setWorkflowTaskTimeout(Duration workflowTaskTimeout)
      Maximum execution time of a single Workflow Task. In the majority of cases there is no need to change this timeout. Note that this timeout is not related to the overall Workflow duration in any way. It defines for how long the Workflow can get blocked in the case of a Workflow Worker crash.

      Default is 10 seconds. Maximum value allowed by the Temporal Server is 120 seconds.

    • setTaskQueue

      public WorkflowOptions.Builder setTaskQueue(String taskQueue)
      Task queue to use for workflow tasks. It should match a task queue specified when creating a Worker that hosts the workflow code.
    • setRetryOptions

      public WorkflowOptions.Builder setRetryOptions(RetryOptions retryOptions)
    • setCronSchedule

      public WorkflowOptions.Builder setCronSchedule(String cronSchedule)
    • setMemo

      public WorkflowOptions.Builder setMemo(Map<String,Object> memo)
      Specifies additional non-indexed information in result of list workflow. The type of value can be any object that are serializable by DataConverter
    • setSearchAttributes

      @Deprecated public WorkflowOptions.Builder setSearchAttributes(Map<String,?> searchAttributes)
      Specifies Search Attributes map searchAttributes that will be attached to the Workflow. Search Attributes are additional indexed information attributed to workflow and used for search and visibility.

      The search attributes can be used in query of List/Scan/Count workflow APIs. The key and its value type must be registered on Temporal server side.

      Supported Java types of the value:

      • String
      • Long, Integer, Short, Byte
      • Boolean
      • Double
      • OffsetDateTime
      • Collection of the types above
    • setTypedSearchAttributes

      public WorkflowOptions.Builder setTypedSearchAttributes(SearchAttributes typedSearchAttributes)
      Specifies Search Attributes that will be attached to the Workflow. Search Attributes are additional indexed information attributed to workflow and used for search and visibility.

      The search attributes can be used in query of List/Scan/Count workflow APIs. The key and its value type must be registered on Temporal server side.

    • setContextPropagators

      public WorkflowOptions.Builder setContextPropagators(@Nullable List<ContextPropagator> contextPropagators)
      This list of context propagators overrides the list specified on WorkflowClientOptions.getContextPropagators().
      This method is uncommon, the majority of users should just set WorkflowClientOptions.getContextPropagators()
      Parameters:
      contextPropagators - specifies the list of overriding context propagators, null means no overriding.
    • setDisableEagerExecution

      public WorkflowOptions.Builder setDisableEagerExecution(boolean disableEagerExecution)
      If WorkflowClient is used to create a WorkerFactory that is
      • started
      • has a non-paused worker on the right task queue
      • has available workflow task executor slots

      and such a WorkflowClient is used to start a workflow, then the first workflow task could be dispatched on this local worker with the response to the start call if Server supports it. This option can be used to disable this mechanism.

      Default is true

      WARNING: Eager start does not respect worker versioning. An eagerly started workflow may run on any available local worker even if that worker is not in the default build ID set.

      Parameters:
      disableEagerExecution - if true, an eager local execution of the workflow task will never be requested even if it is possible.
    • setStartDelay

      public WorkflowOptions.Builder setStartDelay(Duration startDelay)
      Time to wait before dispatching the first workflow task. A signal from signal with start will not trigger a workflow task. Cannot be set the same time as a CronSchedule.
    • setStaticSummary

      @Experimental public WorkflowOptions.Builder setStaticSummary(String staticSummary)
      Single-line fixed summary for this workflow execution that will appear in UI/CLI. This can be in single-line Temporal Markdown format.

      Default is none/empty.

    • setStaticDetails

      @Experimental public WorkflowOptions.Builder setStaticDetails(String staticDetails)
      General fixed details for this workflow execution that will appear in UI/CLI. This can be in Temporal Markdown format and can span multiple lines. This is a fixed value on the workflow that cannot be updated.

      Default is none/empty.

    • setRequestId

      @Experimental public WorkflowOptions.Builder setRequestId(String requestId)
      A unique identifier for this start request.

      WARNING: Not intended for User Code.

    • setCompletionCallbacks

      @Experimental public WorkflowOptions.Builder setCompletionCallbacks(List<io.temporal.api.common.v1.Callback> completionCallbacks)
      Callbacks to be called by the server when this workflow reaches a terminal state.

      WARNING: Not intended for User Code.

    • setLinks

      @Experimental public WorkflowOptions.Builder setLinks(List<io.temporal.api.common.v1.Link> links)
      Links to be associated with the workflow.

      WARNING: Not intended for User Code.

    • setOnConflictOptions

      @Experimental public WorkflowOptions.Builder setOnConflictOptions(OnConflictOptions onConflictOptions)
      Set workflow ID conflict options used in conjunction with conflict policy WORKFLOW_ID_CONFLICT_POLICY_USE_EXISTING. If onConflictOptions is set and a workflow is already running, the options specifies the actions to be taken on the running workflow. If not set or use together with any other WorkflowIDConflictPolicy, this parameter is ignored.

      WARNING: Not intended for User Code.

    • setPriority

      @Experimental public WorkflowOptions.Builder setPriority(Priority priority)
      Optional priority settings that control relative ordering of task processing when tasks are backed up in a queue.
    • setVersioningOverride

      public WorkflowOptions.Builder setVersioningOverride(VersioningOverride versioningOverride)
      Sets the versioning override to use when starting this workflow.
    • build

      public WorkflowOptions build()
    • validateBuildWithDefaults

      public WorkflowOptions validateBuildWithDefaults()
      Validates that all required properties are set and fills all other with default parameters.