What is the difference between: calling the generic GetPublishSendEndpoint()
and providing a type for the message being sent and calling the GetSendEndpoint()
and providing a URI parameter?
When would you use one over another?
To my understanding Sending (to a queue) and publishing (to an exchange) are two very different operations, so the idea of a PublishSend endpoint is confusing to me, and the documentation doesn't help.
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 byPublish<T>
, which should make sense as it is onIPublishEndpoint
(and notISendEndpointProvider
).
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:
ConsumeContext
to produce messages (publish, send, respond)IPublishEndpoint
or ISendEndpointProvider
.IPublishEndpoint
or ISendEndpointProvider
whenever possible.IBus
.This is also outlined in the documentation.