Class ActivityOptions.Builder
-
Method Summary
Modifier and TypeMethodDescriptionbuild()mergeActivityOptions(ActivityOptions override) Properties that are set on this builder take precedence over ones found in the annotation.setCancellationType(ActivityCancellationType cancellationType) In case of an activity's scope cancellation the corresponding activity stub call fails with aCanceledFailure.setContextPropagators(List<ContextPropagator> contextPropagators) Note:
This method has extremely limited usage.setDisableEagerExecution(boolean disableEagerExecution) If set to true, will not request eager execution regardless of worker settings.setHeartbeatTimeout(Duration heartbeatTimeoutSeconds) Heartbeat interval.setPriority(Priority priority) Optional priority settings that control relative ordering of task processing when tasks are backed up in a queue.setRetryOptions(RetryOptions retryOptions) RetryOptions that define how an Activity is retried in case of failure.setScheduleToCloseTimeout(Duration scheduleToCloseTimeout) Total time that a workflow is willing to wait for an Activity to complete.setScheduleToStartTimeout(Duration scheduleToStartTimeout) Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker.setStartToCloseTimeout(Duration startToCloseTimeout) Maximum time of a single Activity attempt.setSummary(String summary) Single-line fixed summary for this activity that will appear in UI/CLI.setTaskQueue(String taskQueue) Task queue to use when dispatching activity task to a worker.setVersioningIntent(VersioningIntent versioningIntent) Deprecated.Use Worker Deployments
-
Method Details
-
setScheduleToCloseTimeout
Total time that a workflow is willing to wait for an Activity to complete.ScheduleToCloseTimeout limits the total time of an Activity's execution including retries (use
setStartToCloseTimeout(Duration)to limit the time of a single attempt).Either this option or
setStartToCloseTimeout(Duration)is required.Defaults to unlimited, which is chosen if set to null.
-
setScheduleToStartTimeout
Time that the Activity Task can stay in the Task Queue before it is picked up by a Worker.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
Maximum time of a single Activity 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
setScheduleToCloseTimeout(Duration)is not provided, then this timeout is required. -
setHeartbeatTimeout
Heartbeat interval. Activity must callActivityExecutionContext.heartbeat(Object)before this interval passes after the last heartbeat or the Activity starts. -
setTaskQueue
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. Default is used if set tonull. -
setRetryOptions
RetryOptions that define how an Activity is retried in case of failure.If not provided, the server-defined default activity retry policy will be used. If not overridden, the server default activity retry policy is:
InitialInterval: 1 second BackoffCoefficient: 2 MaximumInterval: 100 seconds // 100 * InitialInterval MaximumAttempts: 0 // Unlimited NonRetryableErrorTypes: []If both
setScheduleToCloseTimeout(Duration)andRetryOptions.Builder.setMaximumAttempts(int)are not set, the Activity will not be retried.To ensure zero retries, set
RetryOptions.Builder.setMaximumAttempts(int)to 1. -
setContextPropagators
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,
ContextPropagators specified onWorkflowClientOptions.getContextPropagators().WorkflowClientOptions.Builder.setContextPropagators(List)is the right place to specifyContextPropagators 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 usesContextPropagators 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 aContextPropagatorthat 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(),nullmeans no overriding- See Also:
-
setCancellationType
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:
-
setDisableEagerExecution
If set to true, will not request eager execution regardless of worker settings. If false, eager execution may still be disabled at the worker level or eager execution may not be requested due to lack of available slots.Eager activity execution means the server returns requested eager activities directly from the workflow task back to this worker which is faster than non-eager which may be dispatched to a separate worker.
Defaults to false, meaning that eager activity execution will be requested if possible.
-
setVersioningIntent
Deprecated.Use Worker DeploymentsSpecifies whether this activity should run on a worker with a compatible Build Id or not. See the variants ofVersioningIntent. -
setSummary
Single-line fixed summary for this activity that will appear in UI/CLI. This can be in single-line Temporal Markdown format.Default is none/empty.
-
setPriority
Optional priority settings that control relative ordering of task processing when tasks are backed up in a queue.Defaults to inheriting priority from the workflow that scheduled the activity.
-
mergeActivityOptions
-
mergeMethodRetry
Properties that are set on this builder take precedence over ones found in the annotation. -
build
-
validateAndBuildWithDefaults
-