Azure/durabletask

How To Raise Event To Sub Orchestrator

Closed this issue · 4 comments

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?

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.

@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.

@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.

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