How to set a Schedule-To-Close Timeout in Java
To set a Schedule-To-Close Timeout, use ActivityOptions.newBuilder.setScheduleToCloseTimeout​.
This or StartToCloseTimeout must be set.
- Type: Duration
- Default: Unlimited.
Note that if WorkflowRunTimeoutand/orWorkflowExecutionTimeoutare defined in the Workflow, all Activity retries will stop when either or both of these timeouts are reached.
You can set Activity Options using an ActivityStub within a Workflow implementation, or per-Activity using WorkflowImplementationOptions within a Worker.
Note that if you define options per-Activity Type options with WorkflowImplementationOptions.setActivityOptions(), setting them again specifically with ActivityStub in a Workflow will override this setting.
- With - ActivityStub- GreetingActivities activities = Workflow.newActivityStub(GreetingActivities.class,
 ActivityOptions.newBuilder()
 .setScheduleToCloseTimeout(Duration.ofSeconds(5))
 .build());
- With - WorkflowImplementationOptions- WorkflowImplementationOptions options =
 WorkflowImplementationOptions.newBuilder()
 .setActivityOptions(
 ImmutableMap.of(
 "GetCustomerGreeting",
 ActivityOptions.newBuilder()
 .setScheduleToCloseTimeout(Duration.ofSeconds(5))
 .build()))
 .build();