@@ -220,6 +220,8 @@ public Builder setMaxConcurrentNexusExecutionSize(int maxConcurrentNexusExecutio
220220 * it to less than 1 if needed. For example, set the number to 0.1 means you want your activity
221221 * to be executed once every 10 seconds. This can be used to protect down stream services from
222222 * flooding. The zero value of this uses the default value. Default is unlimited.
223+ *
224+ * <p>Setting this value to a non-zero value will disable eager execution for activities.
223225 */
224226 public Builder setMaxTaskQueueActivitiesPerSecond (double maxTaskQueueActivitiesPerSecond ) {
225227 this .maxTaskQueueActivitiesPerSecond = maxTaskQueueActivitiesPerSecond ;
@@ -373,7 +375,8 @@ public Builder setStickyQueueScheduleToStartTimeout(Duration timeout) {
373375 * the workflow task back to this worker which is faster than non-eager which may be dispatched
374376 * to a separate worker.
375377 *
376- * <p>Defaults to false, meaning that eager activity execution is permitted
378+ * <p>Defaults to false, meaning that eager activity execution is permitted. Unless you set
379+ * MaxTaskQueueActivitiesPerSecond, then eager execution is disabled.
377380 */
378381 public Builder setDisableEagerExecution (boolean disableEagerExecution ) {
379382 this .disableEagerExecution = disableEagerExecution ;
@@ -685,7 +688,7 @@ private WorkerOptions(
685688 this .maxHeartbeatThrottleInterval = maxHeartbeatThrottleInterval ;
686689 this .defaultHeartbeatThrottleInterval = defaultHeartbeatThrottleInterval ;
687690 this .stickyQueueScheduleToStartTimeout = stickyQueueScheduleToStartTimeout ;
688- this .disableEagerExecution = disableEagerExecution ;
691+ this .disableEagerExecution = maxTaskQueueActivitiesPerSecond > 0 ? true : disableEagerExecution ;
689692 this .useBuildIdForVersioning = useBuildIdForVersioning ;
690693 this .buildId = buildId ;
691694 this .stickyTaskQueueDrainTimeout = stickyTaskQueueDrainTimeout ;
0 commit comments