Common way of getting running and ended workflows

Hi,

Is there a reliable way of querying a workflow without knowing if it’s still running or not?

Currently, I’m querying the worfklow by using:

workflowClient.newWorkflowStub(MyWorkflow.class, workflowId.toString());

But this throws WorkflowNotFoundException in case the workflow has ended. Should I use the history for such workflow to query it’s state / events or is there a way to retrieve the ended workflow to query it the same way I can query a running workflow?

Thanks,
Michał Schielmann

What is your namespace retention period? WorkflowNotFoundException is thrown when a workflow with a given id is not known to the service. It was either never created or was removed after the retention period elapsed.

Thank you for your answer. I’m not configuring a retention period, so I assume it’s a set to a default value. I find it hard to find docs regarding the retention configuration - could you please point me to the docs that describe how I could change the retention value?

Retention period has default value of two days, min is 1 day, and max 30 days currently.
You can change the default via tctl, for example:

tctl namespace update --retention 3

where 3 is in days. Retention period starts for each workflow execution once it completes.

1 Like

Thank you for your answer @tihomir. Is there any other way of setting this value - like via dynamicconfig or is tctl the only option?

Not at this time per namespace. You can use tctl or use the SDK api, specifically UpdateNamespace.

1 Like

Thank you @tihomir!