开发者

NServiceBus: How do I get a subscriber to start processing messing without using generic host?

I am modifying the PubSub sample, and have been playing around with the configuration of NServiceBus. Currently, my EndpointConfig.cs file has configuration like this:

Configure.With(new[] { typeof(IEvent), typeof(NServiceBus.Unicast.Transport.CompletionMessage) })
            .CustomConfigurationSource(new UserConfigurationSource()
               .Register(() => new MsmqTransportConfig { InputQueue = "Subscriber2InputQueue", ErrorQueue = "error", NumberOfWorkerThreads = 1, MaxRetries = 5 }))
            .DefaultBuilder()
            .XmlSerializer()
            .MsmqTransport()
            .IsTransactional(true);

Now I want to change it to just be a console app without the generic host. Here's what I changed:

  1. Changed the project output to be Console app
  2. Changed the startup settings to not invoke the generic host
  3. Moved the configuration above to the Main method like this:

            Configure.With(new[] { typeof(IEvent), typeof(NServiceBus.Unicast.Transport.CompletionMessage) })
          开发者_开发技巧      .CustomConfigurationSource(new UserConfigurationSource()
                   .Register(() => new MsmqTransportConfig { InputQueue = "Subscriber2InputQueue", ErrorQueue = "error", NumberOfWorkerThreads = 1, MaxRetries = 5 }))
                .DefaultBuilder()
                .XmlSerializer()
                .MsmqTransport()
                .IsTransactional(true);
    
    
    
        Console.ReadLine();
    

Is there something else I should be doing to "startup" the subscriber to read messages?


Look at the Async Pages sample to see how to self-host NServiceBus (like in IIS). You're missing .UnicastBus().LoadMessageHandlers().Start().


FYI my config looks something like,

_Bus = NServiceBus.Configure.With()
              .DefaultBuilder()
              .Log4Net(new MyLogAppender())
              .XmlSerializer()
              .MsmqTransport()
                  .IsTransactional(false)
                  .PurgeOnStartup(true)
              .UnicastBus()
                  .ImpersonateSender(false)
                  .DoNotAutoSubscribe()
                  .LoadMessageHandlers()
              .CreateBus()
              .Start();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜