Class WorkerOptions.Builder

  • Enclosing class:
    WorkerOptions

    public static final class WorkerOptions.Builder
    extends java.lang.Object
    • Method Detail

      • setMaxWorkerActivitiesPerSecond

        public WorkerOptions.Builder setMaxWorkerActivitiesPerSecond​(double maxWorkerActivitiesPerSecond)
        Parameters:
        maxWorkerActivitiesPerSecond - Maximum number of activities started per second by this worker. Default is 0 which means unlimited.
        Returns:
        this

        If worker is not fully loaded while tasks are backing up on the service consider increasing setMaxConcurrentActivityTaskPollers(int).

        Note that this is a per worker limit. Use setMaxTaskQueueActivitiesPerSecond(double) to set per task queue limit across multiple workers.

      • setMaxConcurrentActivityExecutionSize

        public WorkerOptions.Builder setMaxConcurrentActivityExecutionSize​(int maxConcurrentActivityExecutionSize)
        Parameters:
        maxConcurrentActivityExecutionSize - Maximum number of activities executed in parallel. Default is 200, which is chosen if set to zero.
        Returns:
        this
      • setMaxConcurrentWorkflowTaskExecutionSize

        public WorkerOptions.Builder setMaxConcurrentWorkflowTaskExecutionSize​(int maxConcurrentWorkflowTaskExecutionSize)
        Parameters:
        maxConcurrentWorkflowTaskExecutionSize - Maximum number of simultaneously executed workflow tasks. Default is 200, which is chosen if set to zero.
        Returns:
        this

        Note that this is not related to the total number of open workflows which do not need to be loaded in a worker when they are not making state transitions.

      • setMaxConcurrentLocalActivityExecutionSize

        public WorkerOptions.Builder setMaxConcurrentLocalActivityExecutionSize​(int maxConcurrentLocalActivityExecutionSize)
        Parameters:
        maxConcurrentLocalActivityExecutionSize - Maximum number of local activities executed in parallel. Default is 200, which is chosen if set to zero.
        Returns:
        this
      • setMaxTaskQueueActivitiesPerSecond

        public WorkerOptions.Builder setMaxTaskQueueActivitiesPerSecond​(double maxTaskQueueActivitiesPerSecond)
        Optional: Sets the rate limiting on number of activities that can be executed per second. This is managed by the server and controls activities per second for the entire task queue across all the workers. Notice that the number is represented in double, so that you can set it to less than 1 if needed. For example, set the number to 0.1 means you want your activity to be executed once every 10 seconds. This can be used to protect down stream services from flooding. The zero value of this uses the default value. Default is unlimited.
      • setWorkflowPollThreadCount

        @Deprecated
        public WorkerOptions.Builder setWorkflowPollThreadCount​(int workflowPollThreadCount)
        Deprecated.
        Use {#setMaxConcurrentWorkflowTaskPollers}
        Number of simultaneous poll requests on workflow task queue. Note that the majority of the workflow tasks will be using host local task queue due to caching. So try incrementing WorkerFactoryOptions.Builder.setWorkflowHostLocalPollThreadCount(int) before this one.

        Default is 2.

      • setMaxConcurrentActivityTaskPollers

        public WorkerOptions.Builder setMaxConcurrentActivityTaskPollers​(int maxConcurrentActivityTaskPollers)
        Number of simultaneous poll requests on activity task queue. Consider incrementing if the worker is not throttled due to `MaxActivitiesPerSecond` or `MaxConcurrentActivityExecutionSize` options and still cannot keep up with the request rate.

        Default is 5.

      • setActivityPollThreadCount

        @Deprecated
        public WorkerOptions.Builder setActivityPollThreadCount​(int activityPollThreadCount)
        Number of simultaneous poll requests on activity task queue. Consider incrementing if the worker is not throttled due to `MaxActivitiesPerSecond` or `MaxConcurrentActivityExecutionSize` options and still cannot keep up with the request rate.

        Default is 5.

      • setLocalActivityWorkerOnly

        public WorkerOptions.Builder setLocalActivityWorkerOnly​(boolean localActivityWorkerOnly)
        If set to true worker would only handle workflow tasks and local activities. Non-local activities will not be executed by this worker.

        Default is false.

      • setDefaultDeadlockDetectionTimeout

        public WorkerOptions.Builder setDefaultDeadlockDetectionTimeout​(long defaultDeadlockDetectionTimeoutMs)
        Parameters:
        defaultDeadlockDetectionTimeoutMs - time period in ms that will be used the detect workflows deadlock. Default is 1000ms, which is chosen if set to zero.

        Specifies an amount of time in milliseconds that workflow tasks are allowed to execute without interruption. If workflow task runs longer than specified interval without yielding (like calling an Activity), it will fail automatically.

        Returns:
        this
        See Also:
        PotentialDeadlockException
      • setMaxHeartbeatThrottleInterval

        public WorkerOptions.Builder setMaxHeartbeatThrottleInterval​(@Nullable
                                                                     java.time.Duration interval)
        Parameters:
        interval - the maximum amount of time between sending each pending heartbeat to the server. Regardless of heartbeat timeout, no pending heartbeat will wait longer than this amount of time to send. Default is 60s, which is chosen if set to null or 0.
        Returns:
        this
      • setDefaultHeartbeatThrottleInterval

        public WorkerOptions.Builder setDefaultHeartbeatThrottleInterval​(@Nullable
                                                                         java.time.Duration interval)
        Parameters:
        interval - the default amount of time between sending each pending heartbeat to the server. This is used if the ActivityOptions do not provide a HeartbeatTimeout. Otherwise, the interval becomes a value a bit smaller than the given HeartbeatTimeout. Default is 30s, which is chosen if set to null or 0.
        Returns:
        this
      • validateAndBuildWithDefaults

        public WorkerOptions validateAndBuildWithDefaults()