polling from nservicebus input queue
I just started writing pub/sub and the way that I doing this is that I will have a console app that runs every x hours and putting processed list as queue message (1 item per message). Now, on the pub side, I want to listen the input queue and as soon as a mes开发者_如何转开发sage arrives, I would like to publish.
I know I need to set the input queue name and polling intervals in the config file, but how do I make so that the pub actually keeps polling from the input queue.
Thanks.
Take a look at this article about scheduling recurring tasks in NSB. I think you can use this technique and eliminate the need for 2 separate processes.
All you should need to do is to create a class that implements IHandleMessages<YourMessageTypeHere>
, and in your initialization code, use
IBus bus = Configure.With()
...
.UnicastBus()
.LoadMessageHandlers()
.CreateBus()
.Start();
LoadMessageHandlers()
will scan the current assembly for IHandleMessages
implementations. Whenever a message arrives, the handler will be invoked.
(Disclaimer: This works for NSB 2.1; I haven't used 2.5 yet.)
精彩评论