0

I have a DurableOrchestrationClient executing a a couple of Activity functions working on a ActivityMessage object - how to I get a handle on the updated ActivityMessage object in the starter function?

e.g. Starter function:

ActivityMessage am = new ActivityMessage();
var orchestrationId = starter.StartNewAsync("O_DispatchExecutor", am);

...>

[FunctionName("O_DispatchExecutor")]
public static async Task<ActivityMessage> 
TaskExecutor([OrchestrationTrigger]DurableOrchestrationContext ctx, ILogger 
log)
{
int index = 0; // 
ActivityMessage input = ctx.GetInput<ActivityMessage>();
for (; index <= input.Rules.Count; index++) {
Rule r = input.Rules.ElementAt(index);
try
{
input = ctx.CallActivityAsync<ActivityMessage>(r.Name, input));
...

Any help will be appreciated

phasse
  • 1
  • 1

1 Answers1

1

The short answer is that you can't directly view the changes made to your ActivityMessage object from the reference in your starter function. However, there are workarounds.

Per the documentation, "Orchestrator functions and activity functions are both triggered by internal queues in the function app's task hub." These queue messages include the function's input, which is serialized/deserialized to/from JSON on enqueue/dequeue, respectively. As a result, you lose the object reference, so it's effectively passed by value.

If you only want to view the updated ActivityMessage once the orchestration completes, return your ActivityMessage at the end of your orchestration. Monitor your orchestration's status in your starter function using DurableOrchestrationClient.CheckStatusAsync. Once the orchestration is complete, retrieve the updated activity message from the DurableOrchestrationStatus.Output property.

If you want to view updates to the ActivityMessage as the orchestration progresses, you'll want to additionally use DurableOrchestrationContext.SetCustomStatus to output your ActivityMessage object to the DurableOrchestrationContext.CustomStatus property as it goes through updates.

Katy Shimizu
  • 1,051
  • 5
  • 9