Context is: Blazor server side.
I’m trying to find a way so that whenever a command is sent the username that triggered the operation will end up in the message headers. I already implemented the header propagation, so that subsequent messages sent by the initial handler will also get the username in their headers.
This works when manually adding the header to the SendOptions before emitting the initial message.
But I’m struggling to find a way so that it can be done automatically with a behavior or outgoing message behavior, without the need to change every invocation of
IMessageSession.Send to include the header in the SendOptions.
From what I understand a behavior as well as a message mutator are a singleton within a process. So all connected users would share the same instance. On the other hand the
Scoped in Blazor. Resulting from this there’s a dependency issue that won’t let me solve the problem at hand. My conclusion from this is, that it’s just not possible because the behavior could not access the current user’s principal due to lifetime differences.
Is anyone familiar with this to confirm my conclusion, or maybe sees a solution I didn’t see yet?
EDIT: I checked Appending username using headers • NServiceBus Samples • Particular Docs but I don’t see how this would help me.