1
votes

I am able to add messages to local MSMQ using nservicebus by below code

var endpointConfiguration = new EndpointConfiguration("Samples.Msmq.Simple");
    var transport = endpointConfiguration.UseTransport<MsmqTransport>();

    endpointConfiguration.SendFailedMessagesTo("error");
    endpointConfiguration.EnableInstallers();
    endpointConfiguration.UsePersistence<InMemoryPersistence>();

    var endpointInstance = await Endpoint.Start(endpointConfiguration)
        .ConfigureAwait(false);
    var myMessage = new MyMessage();
        await endpointInstance.SendLocal(myMessage)
            .ConfigureAwait(false);

But I read at some places that I can send messages to remote MSMQ, see code below

FormatName:Direct=TCP:100.100.100.12\\private$\\remoteTxn

But I am not able to figure how to send to Remote MSMQ using Nservicebus. Anyone can pitch here?

1

1 Answers

0
votes

Instead of using SendLocal you need to either use Send in case of a command or Publish in case of an event.

Using Send means you need to have message routing in place, as that determines what is the destination of the message. Routing could be defined using code, or other means like external files which makes it easier for dev/ops to change the routes at runtime in future.

An overload of the Send method also accepts a destination endpoint, but it is recommended to not mix concerns and keep the routing code separate (hence not using the overload with the destination). More info here.