I have a parent workflow that executes a child workflow that polls a activity that retrieves the status from another service and child workflow sleeps using workflow.await if the status returned from activity is still “InProgress”. We have a workflow execution timeout of X mins.
Is there a way where we can execute a handle or cleanup function to update database etc from workflow ?
I know polling from child workflow is a anti pattern and for now works instead of activity stealing thread with Thread.sleep.
One workaround I can think of is have a global variable with startTime in workflow and each time before poll check the how much time has elapsed using Workflow.currentTime() and if it has elapsed more than timeout secs, call activity to clean up. But I find this pretty hacky eve though its deterministic. Any other better way to handle this ?
Is there an option to catch workflow execution timeout exception in parent workflow and then execute cleanup acitvity ?