'MassTransit Mediator: Payload added by Send/Publish not found in ConsumeContext
I'm using MassTransit mediator to Send/Post messages to my consumers, however I'd like to get some metadata delivered to the consumers as a payload, i.e.
await mediator.Publish(message, ctx => ctx.GetOrAddPayload(() => metadata));
I've looked into MassTransit's code and it seems the payloads from MessageSendContext<T> are not copied to MediatorReceiveContext<T>
So my question is if it is by design or it was somehow overlooked passing the payloads to MediatorReceiveContext<T> .ctor as it has a parameter params object[] payloads which might perfectly do the job.
Solution 1:[1]
This is by design, as coupling between the producer and consumer would introduce inconsistent expectations since payloads are not transferred between producers and consumers with buses. If you need to pass data to a consumer, it should be done using headers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chris Patterson |
