Azure / durabletask

Durable Task Framework allows users to write long running persistent workflows in C# using the async/await capabilities.
Apache License 2.0
1.47k stars 287 forks source link

How To Raise Event To Sub Orchestrator #1003

Closed zpertee closed 8 months ago

zpertee commented 8 months ago

Hello. I'm hoping that I'm missing something basic, but how do I raise an event to a suborchestrator instance? I can get it to work just fine 1 level in, but I'm not sure how to make the secondary hops to get to the suborchestrator instance?

cgillum commented 8 months ago

Where do you want to raise the event from? Generally speaking, you need to get the orchestration instance of the sub-orchestration, either by specifying one at creation time or having the sub orchestration sends its ID to some external location, which can then use it to raise an event back to it. Either way, you'd use the normal "raise event" methods TaskHubClient to target the sub-orchestration.

zpertee commented 8 months ago

@cgillum Sorry, a better problem description would be what to do I do about the fact that CreateSubOrchestrationInstance does not return an OrchestrationInstance like CreateOrchestrationInstanceAsync does. I wasn't positive how a sub orchestrator works, but it seems like it must have its own instance id, because when I attempt to use the instance id of the root orchestrator the event only makes it that far. I can't seem to figure out how to get the instance id of the sub orchestrator.

cgillum commented 8 months ago

@zpertee Right. In this case, you have to create a new instance ID from the parent orchestration and use that to call one of the CreateSubOrchestrationInstance overloads that take an instanceId parameter (like this one). You can use that instanceId to later raise an event to the sub-orchestration.

zpertee commented 8 months ago

@cgillum Thanks, that explains it. I must have missed that overload (sorry).