Class WorkerFactoryOptions.Builder
- Enclosing class:
WorkerFactoryOptions
-
Method Summary
Modifier and TypeMethodDescriptionbuild()setEnableLoggingInReplay(boolean enableLoggingInReplay) setMaxWorkflowThreadCount(int maxWorkflowThreadCount) Maximum number of threads available for workflow execution across all workers created by the Factory.setPlugins(WorkerPlugin... plugins) Sets the worker plugins to use with workers created by this factory.setShutdownCheckInterval(Duration shutdownCheckInterval) Sets the interval between polls when checking for executor termination during shutdown.setUsingVirtualWorkflowThreads(boolean usingVirtualWorkflowThreads) Use Virtual Threads for all workflow threads across all workers created by this factory.setWorkerInterceptors(WorkerInterceptor... workerInterceptors) setWorkflowCacheSize(int workflowCacheSize) To avoid constant replay of code the workflow objects are cached on a worker.setWorkflowHostLocalPollThreadCount(int workflowHostLocalPollThreadCount) Deprecated.not used anymore by JavaSDK, this value doesn't have any effectDeprecated.useWorkerOptions.Builder.setStickyQueueScheduleToStartTimeout(Duration)to specify this value per-worker insteadValidates options and builds with defaults applied.
-
Method Details
-
setWorkflowCacheSize
To avoid constant replay of code the workflow objects are cached on a worker. This cache is shared by all workers created by the Factory. Note that in the majority of situations the number of cached workflows is limited not by this value, but by the number of the threads defined throughsetMaxWorkflowThreadCount(int).Default value is 600
-
setMaxWorkflowThreadCount
Maximum number of threads available for workflow execution across all workers created by the Factory. This includes cached workflows.Default is 600
-
setWorkflowHostLocalTaskQueueScheduleToStartTimeout
@Deprecated public WorkerFactoryOptions.Builder setWorkflowHostLocalTaskQueueScheduleToStartTimeout(Duration timeout) Deprecated.useWorkerOptions.Builder.setStickyQueueScheduleToStartTimeout(Duration)to specify this value per-worker insteadTimeout for a workflow task routed to the "sticky worker" - host that has the workflow instance cached in memory. Once it times out, then it can be picked up by any worker.Default value is 5 seconds.
-
setWorkerInterceptors
-
setPlugins
Sets the worker plugins to use with workers created by this factory. Plugins can modify worker configuration and wrap worker lifecycle.Note: Plugins that implement both
WorkflowClientPluginandWorkerPluginare automatically propagated from the client. Use this method for worker-only plugins that don't need client-side configuration.- Parameters:
plugins- the worker plugins to use- Returns:
- this builder for chaining
- See Also:
-
setEnableLoggingInReplay
-
setUsingVirtualWorkflowThreads
@Experimental public WorkerFactoryOptions.Builder setUsingVirtualWorkflowThreads(boolean usingVirtualWorkflowThreads) Use Virtual Threads for all workflow threads across all workers created by this factory. This option is only supported for JDK >= 21. If set thensetMaxWorkflowThreadCount(int)is ignored.Default is false
-
setWorkflowHostLocalPollThreadCount
@Deprecated public WorkerFactoryOptions.Builder setWorkflowHostLocalPollThreadCount(int workflowHostLocalPollThreadCount) Deprecated.not used anymore by JavaSDK, this value doesn't have any effect -
setShutdownCheckInterval
@Experimental public WorkerFactoryOptions.Builder setShutdownCheckInterval(Duration shutdownCheckInterval) Sets the interval between polls when checking for executor termination during shutdown. Lower values speed up shutdown at the cost of more frequent polling.Default is 250ms, which is suitable for production. For test environments, consider setting a much lower value (e.g., 1ms) to minimize teardown overhead.
- Parameters:
shutdownCheckInterval- the interval between shutdown polls. Must be positive.- Returns:
- this builder for chaining
-
build
-
validateAndBuildWithDefaults
Validates options and builds with defaults applied.Note: If plugins are configured via
setPlugins(WorkerPlugin...), they will have an opportunity to modify options after this method is called, when the options are passed toWorkerFactory.newInstance(io.temporal.client.WorkflowClient). This means validation performed here occurs before plugin modifications. In most cases, users should simply callbuild()and let the factory creation handle validation.- Returns:
- validated options with defaults applied
-