views:

73

answers:

2

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.

A: 

I would try not configuring an input queue. Bus.Send will use an internal outbound queue to send messages.

Adam Fyles
It doesnt appear to be that easy.I have tried to reduce my configuration to:Configure.WithWeb().StructureMapBuilder(ObjectFactory.Container).XmlSerializer().UnicastBus().ImpersonateSender(false).CreateBus().Start()and remove the MsMqTransportConfig section of my web.config but it throws an exception in the Configure()-method.
kfuglsang
I have the following in an ASP.NET app in a HttpModule with no MsmqTransportConfig section in the web.config and am having success with it:Bus = NServiceBus.Configure.WithWeb() .Log4Net() .DefaultBuilder() .XmlSerializer() .MsmqTransport() .IsTransactional(false) .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .CreateBus() .Start();I hope it's not an MVC thing, but NSB should not be peeking a queue..
Adam Fyles
I get a NullReferenceException during configuration if I do it without the MsmqTransportConfig-section in my webconfig.
kfuglsang
Not sure on that one, where are you starting the bus? What version of NSB are you using?
Adam Fyles
I am configuring NServiceBus in my Application_Start() method.I'm using NServiceBus 2.1.0.0 (according to the assembly; I downloaded it about a week ago).
kfuglsang
I'm on 2.0, I'll have to try on 2.1, may be a bug..
Adam Fyles
A: 

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

Andreas
If I dont call bus.Start() I cannot send messages.The bus is not started yet, call Bus.Start() before attempting to use the bus. Exception Details: System.InvalidOperationException: The bus is not started yet, call Bus.Start() before attempting to use the bus.Line 21: public void FireAndForget(IMessage message)Line 22: {Line 23: _bus.Send(message);Line 24: }
kfuglsang
My wrong, Start needs to be called. Edited my answer to reflect this. Will check 2.1 as well, but given that it's not stable I suggest that you move to 2.0 if you're having troubles
Andreas