Skip to content

Commit ae6597f

Browse files
Fix schedule workflow action retry policy (#2082)
Fix schedule workflow action retry policy
1 parent 0d7ae22 commit ae6597f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

temporal-sdk/src/main/java/io/temporal/internal/client/ScheduleProtoUtil.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package io.temporal.internal.client;
2222

2323
import static io.temporal.internal.common.HeaderUtils.toHeaderGrpc;
24+
import static io.temporal.internal.common.RetryOptionsUtils.toRetryPolicy;
2425

2526
import com.google.common.base.MoreObjects;
2627
import com.google.common.base.Preconditions;
@@ -36,6 +37,7 @@
3637
import io.temporal.api.workflow.v1.NewWorkflowExecutionInfo;
3738
import io.temporal.client.WorkflowOptions;
3839
import io.temporal.client.schedules.*;
40+
import io.temporal.common.RetryOptions;
3941
import io.temporal.common.context.ContextPropagator;
4042
import io.temporal.common.converter.DataConverter;
4143
import io.temporal.common.converter.EncodedValues;
@@ -128,6 +130,11 @@ public ScheduleAction actionToProto(io.temporal.client.schedules.ScheduleAction
128130
workflowRequest.setInput(inputArgs.get());
129131
}
130132

133+
RetryOptions retryOptions = wfOptions.getRetryOptions();
134+
if (retryOptions != null) {
135+
workflowRequest.setRetryPolicy(toRetryPolicy(retryOptions));
136+
}
137+
131138
if (startWorkflowAction.getOptions().getMemo() != null) {
132139
Map<String, Payload> memo = new HashMap<>();
133140
for (Map.Entry<String, Object> item :

temporal-sdk/src/test/java/io/temporal/client/schedules/ScheduleTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import io.temporal.api.enums.v1.ScheduleOverlapPolicy;
2626
import io.temporal.client.WorkflowOptions;
27+
import io.temporal.common.RetryOptions;
2728
import io.temporal.common.converter.EncodedValues;
2829
import io.temporal.common.interceptors.ScheduleClientInterceptor;
2930
import io.temporal.testing.internal.SDKTestWorkflowRule;
@@ -301,10 +302,12 @@ public void describeSchedules() {
301302
.setMemo(Collections.singletonMap("memokey2", "memoval2"))
302303
.build();
303304
String scheduleId = UUID.randomUUID().toString();
305+
RetryOptions retryOptions = RetryOptions.newBuilder().setMaximumAttempts(1).build();
304306
WorkflowOptions wfOptions =
305307
WorkflowOptions.newBuilder()
306308
.setWorkflowId("test")
307309
.setTaskQueue(testWorkflowRule.getTaskQueue())
310+
.setRetryOptions(retryOptions)
308311
.setMemo(Collections.singletonMap("memokey1", "memoval1"))
309312
.build();
310313

@@ -360,7 +363,7 @@ public void describeSchedules() {
360363
//
361364
Assert.assertEquals(scheduleId, description.getId());
362365
Assert.assertEquals("memoval2", description.getMemo("memokey2", String.class));
363-
//
366+
// Assert action
364367
Assert.assertEquals(
365368
ScheduleActionStartWorkflow.class, description.getSchedule().getAction().getClass());
366369
ScheduleActionStartWorkflow startWfAction =
@@ -372,6 +375,7 @@ public void describeSchedules() {
372375
(EncodedValues) startWfAction.getOptions().getMemo().get("memokey1");
373376
String memoValue = encodedMemo.get(0, String.class);
374377
Assert.assertEquals("memoval1", memoValue);
378+
Assert.assertEquals(startWfAction.getOptions().getRetryOptions(), retryOptions);
375379
//
376380
Assert.assertEquals(
377381
ScheduleSpec.newBuilder(description.getSchedule().getSpec())

0 commit comments

Comments
 (0)