I need to setup a temporal cron job (cannot use temporal schedule) using the Java SDK which generates daily reports so the workflow needs a context of date which can be passed to it. When a workflow execution fails, is there a way to restart it or do I start a new workflow execution? And do I remove the setCronSchedule from workflow options when restarting the workflow?
When a workflow execution fails, is there a way to restart it or do I start a new workflow execution?
To re-run a failed workflow execution, start a new workflow with the specific context date passed to it.
And do I remove the setCronSchedule from workflow options when restarting the workflow?
The workflow re-run doesn’t need a cron schedule set since it’s a once-off execution. Your original daily report cron job will continue to execute workflows on the schedule set in setCronSchedule. A Temporal Cron Job does not stop spawning Runs until it has been Terminated or until the Workflow Execution Timeout (set by you when defining the cron job) has been reached.
If a workflow execution spawned by temporal cron job fails, how do I restart it from the point of failure?
You need to make sure in your workflow code that your new workflow can “resume” from a set state.
For example, your workflow does A B C D E and fails at C.
Write workflow code that allows you to create a new workflow with a payload that says “here is the information needed to resume from step C”.