Search code examples
exceptionmsmqnservicebus

NServiceBus without input queue


Is it possible to use NServiceBus in an application without having any input queues?

Reason is, I have an ASP.NET MVC application that sends messages to other applications when something happens (e.g. a new user registers). The web application never recieves any responses or other messages and therefore I would like not to bog the app. with the msmq peeking which throws an exception every second.


Solution

  • That is supported, just remove the msmstranport config section and all should be fine. This works against 2.0.1281.0 (net4) version of NServiceBus with no app.config present

    using NServiceBus;
    
        namespace SendOnlyEndpoint.Custom
        {
            public class Program
            {
                static void Main(string[] args)
                {
                    var bus = Configure.With()
                        .DefaultBuilder()
                        .XmlSerializer()
                        .MsmqTransport()
                        .UnicastBus()
                        .CreateBus()
                        .Start();
    
                    bus.Send("SendOnlyDestination",new TestMessage());
                }
            }
    
            public class TestMessage : IMessage
            {
            }
        }
    

    More info on send only endpoints here