@@ -892,11 +892,14 @@ public <T, E extends Exception> WorkflowHandle<T, E> executeWorkflow(
892892 WorkflowInfo parent ,
893893 CompletableFuture <String > latch ) {
894894
895+ Integer maxRetries = workflow .maxRecoveryAttempts () > 0 ? workflow .maxRecoveryAttempts () : null ;
896+
895897 if (options .queueName != null ) {
896898 return enqueueWorkflow (
897899 workflow .name (),
898900 workflow .className (),
899901 workflow .instanceName (),
902+ maxRetries ,
900903 args ,
901904 options ,
902905 parent ,
@@ -924,6 +927,7 @@ public <T, E extends Exception> WorkflowHandle<T, E> executeWorkflow(
924927 workflow .name (),
925928 workflow .className (),
926929 workflow .instanceName (),
930+ maxRetries ,
927931 args ,
928932 workflowId ,
929933 null ,
@@ -1022,6 +1026,7 @@ public static <T, E extends Exception> WorkflowHandle<T, E> enqueueWorkflow(
10221026 String name ,
10231027 String className ,
10241028 String instanceName ,
1029+ Integer maxRetries ,
10251030 Object [] args ,
10261031 ExecuteWorkflowOptions options ,
10271032 WorkflowInfo parent ,
@@ -1051,6 +1056,7 @@ public static <T, E extends Exception> WorkflowHandle<T, E> enqueueWorkflow(
10511056 name ,
10521057 className ,
10531058 instanceName ,
1059+ maxRetries ,
10541060 args ,
10551061 workflowId ,
10561062 queueName ,
@@ -1084,6 +1090,7 @@ private static WorkflowInitResult preInvokeWorkflow(
10841090 String workflowName ,
10851091 String className ,
10861092 String instanceName ,
1093+ Integer maxRetries ,
10871094 Object [] inputs ,
10881095 String workflowId ,
10891096 String queueName ,
@@ -1106,6 +1113,7 @@ private static WorkflowInitResult preInvokeWorkflow(
11061113 Long deadlineEpochMs =
11071114 queueName != null ? null : deadline != null ? deadline .toEpochMilli () : null ;
11081115
1116+ final int retries = maxRetries == null ? Constants .DEFAULT_MAX_RECOVERY_ATTEMPTS : maxRetries ;
11091117 WorkflowStatusInternal workflowStatusInternal =
11101118 new WorkflowStatusInternal (
11111119 workflowId ,
@@ -1135,7 +1143,7 @@ private static WorkflowInitResult preInvokeWorkflow(
11351143 WorkflowInitResult [] initResult = {null };
11361144 DbRetry .run (
11371145 () -> {
1138- initResult [0 ] = systemDatabase .initWorkflowStatus (workflowStatusInternal , 3 );
1146+ initResult [0 ] = systemDatabase .initWorkflowStatus (workflowStatusInternal , retries );
11391147 });
11401148
11411149 if (parentWorkflow != null ) {
0 commit comments