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 ?
Thanks for the reply! I meant hacky since, I have to now increase the childworkflow execution timeout to say T + X secs where X is the polling interval when activity is called for status check. Now in the loop which i run in my workflow i have to check if Workflow start time - curr time > T then break and execute clean up activity. i might have to increase the execution timeout to larger value to make sure i give enough time for cleanup activity gets chance. Also becoming hard to unit test this.