We have multiple activities and child-workflows which need output of already executed activities/child-workflows. We are thinking about passing a Dictionary<string, object> to parent workflow and all child-workflows/activities. Each child-workflow/activity append their result to same input and return it as output. This is solving the problem but with a catch. Temporal UI result of each activity is now corrupted as it contains the whole result (including inputs/outputs of all previous activities). To counter this we used Interceptor like below hoping it will not corrupt the Temporal UI but it is giving the same behavior.
public class MergeOutputActivityInterceptor : ActivityInboundInterceptor
{
internal MergeOutputActivityInterceptor(ActivityInboundInterceptor next) : base(next) { }
public override async Task<object?> ExecuteActivityAsync(ExecuteActivityInput input)
{
var result = await Next.ExecuteActivityAsync(input);
if (result is Dictionary<string, object> resultDict && input.Args[0] is Dictionary<string, object> inputDict)
{
foreach (var item in resultDict)
{
inputDict[item.Key] = item.Value;
}
return inputDict;
}
return result;
}
}
This can be solved by moving the merging logic inside Workflow after activity/child-workflow is completed. But then that logic needs to be added after each activity completion which is a not the best way to do it.
Any other ways this can be achieved?