SendOnly in NServiceBus

When creating an NServiceBus SendOnly endpoint, the goal is to simply start and forget, i.e. just send a message and then someone will take care of it. It seems that I need to. I do not need a connection between the bus and the messages processing the system. System "A" wants to tell system "B" about something.

Well, creating a SendOnly endpoint is very simple, but for a system that listens for messages from a SendOnly endpoint.

I am trying to configure a listener in a command line project that will process messages. Messages are sent to the queue, but they are not processed by system "B".

Is this the wrong approach? Is excess bus for this type of function?

System A:

public class Program
{
    static void Main(string[] args)
    {
        var container = new UnityContainer();

        var bus = Configure.With()
            .UnityBuilder(container)
            .JsonSerializer()
            .Log4Net()
            .MsmqTransport()
            .UnicastBus()
            .SendOnly();

        while(true)
        {
            Console.WriteLine("Send a message");
            var message = new Message(Console.ReadLine());
            bus.Send(message);
        }
    }
}

System B:

class Program
{
    static void Main(string[] args)
    {
        var container = new UnityContainer();

        var bus = Configure.With()
            .UnityBuilder(container)
            .JsonSerializer()
            .Log4Net()
            .MsmqTransport()
            .UnicastBus()
            .LoadMessageHandlers()
            .CreateBus()
            .Start();

        Console.WriteLine("Waiting for messages...");

        while(true)
        {

        }
    }
}

public class MessageHandler : IHandleMessages<Message>
{
    public void Handle(Message message)
    {
        Console.WriteLine(message.Data);
    }
}

public class Message : IMessage
{
    public Message()
    {

    }

    public Message(string data)
    {
        Data = data;
    }

    public string Data { get; set; }
} 
+5
1

MessageEndpointMappings :

  • DLL , (, "" )
  • , System B ( , snapin MSMQ ).
<add Messages="Messages" Endpoint="SystemB" />

NServiceBus 3 .

, NServiceBus.Host .

+5

All Articles