I have a fairly simple SendOnly API endpoint that I wish to include a custom header when sending the message.
Building from the samples, I have a class that has IMessageSession injected into it, and from there calling publish passing some send options. (nothing fancy was done in endpoint configuration for the IMessageSession to be injected, its just worked)
My issue is that the custom header doesnt seem to be added to the message. First question I suppose, does IMessageSession support custom headers in this manner. I’ve seen some discussion about some header and transactional things that it doesnt support. But the method supports the syntax so I’m thinking it should work??
Second, if I need to use IMessageHandlerContext instead, how can I get that to do dependency injected? Right now I’m using AspCore 3.1 with the MS default container. NSB 7.7.0
Thanks.
sample code
public SimpleApi(IMessageSession messageSession)
{
_messageSession = messageSession;
}
public async Task PublishEvent(object message)
{
var sendOptions = new PublishOptions();
sendOptions.SetHeader("MyCustomHeader", "MyCustomValue");
await _messageSession.Publish(message, sendOptions);
}