cadence-java-client icon indicating copy to clipboard operation
cadence-java-client copied to clipboard

Need samples for how to fetch a workflow result only if available

Open toddlipcon opened this issue 6 years ago • 1 comments

In my use case, given a workflow ID, I'd like to get the result if the workflow is complete, and otherwise immediately return a "PENDING" result. I'm able to achieve this by using getResult() with a short timeout (eg 10ms). However, that timeout seems to also apply if the cadence service is slow to return (ie it's a true timeout). What I'd like is semantics like "take as long as you need to find the status of the workflow, but if the workflow is still running, don't block on it".

If this is possible, would be good to have documentation added for this.

toddlipcon avatar Aug 28 '19 00:08 toddlipcon

It looks like distinguishing among the long poll and the short poll for getResult is non trivial. So we decided to postpone this change for now. The proposed workaround is to use the DescribeWorkflowExecution service call to find out if a workflow is completed and then call the getResult once it is.

mfateev avatar Sep 17 '19 00:09 mfateev