The Problem:
I am implementing a Nexus Service using the .NET SDK. In my WorkflowRunOperationHandler, I receive headers from the incoming Nexus request via WorkflowRunOperationContext.HandlerContext.Headers. I need to propagate specific headers to the Workflow being started by context.StartWorkflowAsync.
However, the WorkflowOptions passed to StartWorkflowAsync does not expose a Headers property.
[NexusOperationHandler]
public IOperationHandler<IMyNexusService.WorkflowStartInput, IMyNexusService.WorkflowStartOutput>
StartWorkflowAsync()
{
return WorkflowRunOperationHandler.FromHandleFactory((WorkflowRunOperationContext context,
IMyNexusService.WorkflowStartInput input) =>
{
var payloadConverter = DataConverter.Default.PayloadConverter;
// Get headers from execution context and convert to Temporal Payload format
var headers = new Dictionary<string, Payload>();
if (context.HandlerContext.Headers is not null && context.HandlerContext.Headers.Count > 0)
{
headers["__my_context_key"] = payloadConverter.ToPayload(context.HandlerContext.Headers);
}
return context.StartWorkflowAsync(
(IMyNexusService wf) => wf.RunAsync(
new IMyNexusService.WorkflowStartInput(input.WorkflowId, input.Questions)),
new WorkflowOptions
{
Id = input.WorkflowId,
TaskQueue = "nexus-task-queue",
});
});
}
}
I have attempted to use the standard Interceptor pattern, but I’ve found that none of the following interceptors are triggered when a Nexus handler initiates a workflow:
-
INexusInboundInterceptor: This is getting invoked while invoking the nexus operation handler which is working fine, but is there anything for nexus outbound request, I was expecting Workflow start request will be handled by the TemporalClient outbound interceptor but it’s not working. -
IWorkflowOutboundInterceptor: Does not make any sense but was trying to figure out all the possibilities. -
ITemporalClientOutboundInterceptor: TheStartWorkflowAsynccall inside the NexusWorkflowRunOperationContextseems to bypass the client outbound interceptor pipeline entirely.
Expectation:
My goal is to achieve seamless header propagation from the Nexus entry point to the Workflow execution. Specifically:
-
I receive a header in the Nexus Operation Handler (via
context.HandlerContext.Headers). -
I want to pass this header into the
StartWorkflowAsynccall. -
Crucially, I expect that when this workflow starts, my registered
WorkflowInboundInterceptorshould be triggered, allowing it to extract that header and set up theAsyncLocalstate used by the rest of my workflow logic.
Thank you for your help in advance, and let me know if any additional details required to understand the context.