Is there a way to know in the IDurableOrchestrationContext if the instance was already run #2479
-
Hi, I'm using IDurableOrchestrationClient.Restart with the parameter restartWithNewInstanceId = false to keep the same InstanceID. What I need to know inside the orchestration context, is if the Instance is actually coming from that Restart call or is a brand new execution, is there a way to know that from within the Durable Orchestration Context? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I'm curious to know what you would do if that information, if available, because that might depend on the specific strategy. But I think one way to know if it's a new instance or not is to simply check |
Beta Was this translation helpful? Give feedback.
-
Suggestion 1: Create a Restart extension that use a new ID that is composed by the previous ID + more information. For instance, MyWorkflowId-Restarted. That would be pretty easy to check and to sanitize to the original ID. Suggestion 2: Make your orchestration function input to use a common interface that has If you don't mind making your restart function aware the orchestration input class, that should be even easier. Check the restart implementation: |
Beta Was this translation helpful? Give feedback.
-
There isn't a way from inside the orchestration to distinguish a new orchestration created for the first time or a recreated orchestration instance. Another strategy to consider is whether you can solve your problem using To do this, you'd need to update the orchestration code to call |
Beta Was this translation helpful? Give feedback.
Suggestion 1: Create a Restart extension that use a new ID that is composed by the previous ID + more information. For instance, MyWorkflowId-Restarted. That would be pretty easy to check and to sanitize to the original ID.
Suggestion 2: Make your orchestration function input to use a common interface that has
bool Restarted
. Create a Restart extension that cast the 'status.Input' to your common input interface and set it to True. Or you could make that an int and increment a counter.If you don't mind making your restart function aware the orchestration input class, that should be even easier.
Check the restart implementation: