Class ActivityOptions.Builder
- java.lang.Object
-
- io.temporal.activity.ActivityOptions.Builder
-
- Enclosing class:
- ActivityOptions
public static final class ActivityOptions.Builder extends java.lang.Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActivityOptions
build()
ActivityOptions.Builder
mergeActivityOptions(ActivityOptions override)
ActivityOptions.Builder
mergeMethodRetry(MethodRetry r)
Properties that are set on this builder take precedence over ones found in the annotation.ActivityOptions.Builder
setCancellationType(ActivityCancellationType cancellationType)
In case of an activity's scope cancellation the corresponding activity stub call fails with aCanceledFailure
.ActivityOptions.Builder
setContextPropagators(java.util.List<ContextPropagator> contextPropagators)
Note:
This method has extremely limited usage.ActivityOptions.Builder
setHeartbeatTimeout(java.time.Duration heartbeatTimeoutSeconds)
Heartbeat interval.ActivityOptions.Builder
setRetryOptions(RetryOptions retryOptions)
RetryOptions that define how activity is retried in case of failure.ActivityOptions.Builder
setScheduleToCloseTimeout(java.time.Duration scheduleToCloseTimeout)
Total time that a workflow is willing to wait for Activity to complete.ActivityOptions.Builder
setScheduleToStartTimeout(java.time.Duration scheduleToStartTimeout)
Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker.ActivityOptions.Builder
setStartToCloseTimeout(java.time.Duration startToCloseTimeout)
Maximum time of a single Activity execution attempt.ActivityOptions.Builder
setTaskQueue(java.lang.String taskQueue)
Task queue to use when dispatching activity task to a worker.ActivityOptions
validateAndBuildWithDefaults()
-
-
-
Method Detail
-
setScheduleToCloseTimeout
public ActivityOptions.Builder setScheduleToCloseTimeout(java.time.Duration scheduleToCloseTimeout)
Total time that a workflow is willing to wait for Activity to complete.ScheduleToCloseTimeout limits the total time of an Activity's execution including retries (use StartToCloseTimeout to limit the time of a single attempt).
Either this option or StartToClose is required.
Defaults to unlimited.
-
setScheduleToStartTimeout
public ActivityOptions.Builder setScheduleToStartTimeout(java.time.Duration scheduleToStartTimeout)
Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker. Do not specify this timeout unless using host specific Task Queues for Activity Tasks are being used for routing.ScheduleToStartTimeout is always non-retryable. Retrying after this timeout doesn't make sense as it would just put the Activity Task back into the same Task Queue.
Defaults to unlimited.
-
setStartToCloseTimeout
public ActivityOptions.Builder setStartToCloseTimeout(java.time.Duration startToCloseTimeout)
Maximum time of a single Activity execution attempt.Note that the Temporal Server doesn't detect Worker process failures directly. It relies on this timeout to detect that an Activity that didn't complete on time. So this timeout should be as short as the longest possible execution of the Activity body. Potentially long-running Activities must specify HeartbeatTimeout and call
ActivityExecutionContext.heartbeat(Object)
periodically for timely failure detection.If ScheduleToClose is not provided then this timeout is required.
Defaults to the ScheduleToCloseTimeout value.
-
setHeartbeatTimeout
public ActivityOptions.Builder setHeartbeatTimeout(java.time.Duration heartbeatTimeoutSeconds)
Heartbeat interval. Activity must callActivityExecutionContext.heartbeat(Object)
before this interval passes after the last heartbeat or the Activity starts.
-
setTaskQueue
public ActivityOptions.Builder setTaskQueue(java.lang.String taskQueue)
Task queue to use when dispatching activity task to a worker. By default, it is the same task list name the workflow was started with.
-
setRetryOptions
public ActivityOptions.Builder setRetryOptions(RetryOptions retryOptions)
RetryOptions that define how activity is retried in case of failure. If this is not set, then the server-defined default activity retry policy will be used. To ensure zero retries, set maximum attempts to 1.
-
setContextPropagators
public ActivityOptions.Builder setContextPropagators(java.util.List<ContextPropagator> contextPropagators)
Note:
This method has extremely limited usage. The majority of users should just setWorkflowClientOptions.getContextPropagators()
Both "client" (workflow worker) and "server" (activity worker) sides of context propagation from a workflow to an activity exist in a worker process (potentially the same one), so they typically share the same worker options. Specifically,
ContextPropagator
s specified onWorkflowClientOptions.getContextPropagators()
.WorkflowClientOptions.Builder.setContextPropagators(List)
is the right place to specifyContextPropagator
s between Workflow and an Activity.
Specifying context propagators with this method overrides them only on the "client" (workflow) side and can't be automatically promoted to the "server" (activity worker), which always usesContextPropagator
s fromWorkflowClientOptions.getContextPropagators()
The only legitimate usecase for this method is probably a situation when the specific activity is implemented in a different language and in a completely different worker codebase and in that case setting aContextPropagator
that is applied only on a "client" side could make sense.
This is also why there is no equivalent method onLocalActivityOptions
.- Parameters:
contextPropagators
- specifies the list of context propagators to use during propagation from a workflow to the activity with theseActivityOptions
. This list overrides the list specified onWorkflowClientOptions.getContextPropagators()
,null
means no overriding- See Also:
- Rejected feature reqest for LocalActivityOption#contextPropagators
-
setCancellationType
public ActivityOptions.Builder setCancellationType(ActivityCancellationType cancellationType)
In case of an activity's scope cancellation the corresponding activity stub call fails with aCanceledFailure
.- Parameters:
cancellationType
- Defines the activity's stub cancellation mode. The default value isActivityCancellationType.TRY_CANCEL
- See Also:
ActivityCancellationType
-
mergeActivityOptions
public ActivityOptions.Builder mergeActivityOptions(ActivityOptions override)
-
mergeMethodRetry
public ActivityOptions.Builder mergeMethodRetry(MethodRetry r)
Properties that are set on this builder take precedence over ones found in the annotation.
-
build
public ActivityOptions build()
-
validateAndBuildWithDefaults
public ActivityOptions validateAndBuildWithDefaults()
-
-