Handle cleanup for workflow timeouts

Please advise on how we could handle workflow timeout cleanup where once the workflow times out, the application needs to update the database to handle states for out usecase. Anyway we could approach this?

Hello @Anjula_Paulus

please see Recommended way for running cleanup activity on workflow timeout

Could you provide an example on using timers @antonio.perez ? I block a workflow based on a boolean and update the boolean variable to complete the workflow execution. How is to do the cleanup using a timer based on this implementation?

Use Workflow.await(timeout, ()->booleanVariable) to await up to a timeout.

What is the Exception I need to catch and handle to update my table on Workflow timeout? @maxim


As the linked post (Recommended way for running cleanup activity on workflow timeout) states, do not rely on workflowTimeout to deal with business logic, use a timer instead.

Your workflow code won’t throw any exception when the workflow execution is timed-out.

Workflow.await returns false if the timeout is reached.

I have added the following as suggested.

        boolean executionCompleted = Workflow.await(timeout, () -> isWorkflowDone);

The timeout happens but does not print the value of executionCompleted. Note that isWorkflowDone is updated by a signal method. What could be the reason for this? It does not execute anything after the await.

Could you post the workflow history?

Remove the workflow execution/run timeout, as you want to rely on the timer inside the workflow code.

Thank you @maxim