When using RabbitMQ, if you use MassTransit's default routing, you can almost always use publish 100% of the time. As in, just call Publish<T>
. I follow this advice almost 100% of the time, and with good reason. It's meant to make it easy and avoids the need to configure send addresses because "OMG commands have to be sent." That's nonsense, and I talk about it in several videos.
My previous answer on this subject is also relevant, stop trying to build routing around a framework that already has routing.
And GetPublishSendEndpoint<T>
is really just an internal methods used by Publish<T>
, which should make sense as it is on IPublishEndpoint
(and not ISendEndpointProvider
).
Also, you should be using one of those two interfaces in consumer dependencies, whereas in the consumer you should always use ConsumeContext
, to produce messages.
In summary:
- In a consumer, using
ConsumeContext
to produce messages (publish, send, respond)
- In a consumer dependency, using
IPublishEndpoint
or ISendEndpointProvider
.
- Outside of a consumer, use
IPublishEndpoint
or ISendEndpointProvider
whenever possible.
- Last resort, and I mean the absolute last resort, use
IBus
.
This is also outlined in the documentation.