Hi, I am working on a temporal workflow that calls other services and want to use RetryOptions
woth something like setMaximumAttempts(4)
. After the last attempt, before the workflow fails completely without another retry, I would like to change an internal status
value to my own failed status. Something like status = WorkflowStatus.FAILED
, is there some nice way how I can do this, please?
Hello @Dominik_Labas
sorry, it is not clear to me if you are setting setMaximumAttempts
to the workflow or the activity.
and can I ask what is your use case?
Hi @antonio.perez,
thanks for the quick response. I wanted to set it for the workflow, but what I actually needed was to set it for the activity and catch ActivityFailure
.
Yes ActivityFailure is delivered to your workflow code after all activity retries, similarly you can catch ChildWorkflowFailure for child workflow invocations inside your workflow code.
Note that you can also restrict the amount of retries via ActivityOptions->ScheduleToClose timeout. StartToClose is timeout for a single activity invocation, ScheduleToClose is timeout that includes all retries as well. Often ScheduleToClose can be more useful than setting max retries, see video here.