NServiceBus with Data driven approach
I have a console app (C#), say App1 that runs every x hours to grab a list of people, and then filter the list by some criteria, and creates “cleaner” list. I also have another console app, say App2 that runs every x hours to grab the list created by App1 and does something. I would like to make App1 as “publisher” and App2 as “subscriber”. I want to pass a record at a time or whole list to subscriber. All the reading I have done on the NServiceBus web site, the communication is done through “message” and did not see any examples where publisher (App1) triggers the subscriber (App2) with actual data, “Hey, here is data xyz, do your job”.
Has anybody have experience usi开发者_StackOverflowng NSeviceBus with data driven trigger approach? Is this possible with NServiceBus?Thanks.
You usually publish what is called Events, aka things that has happened in the past. It sounds to me that your app1 is telling app2 to do something aka a Command. Commands are Sent not published.
You can have your app1 do a bus.Send(new CleanUpCustomerCommand()) to app2. In the command you can pass whatever data you need. Each message is a UoW so only pass the entire list if you want the cleanup of all customers performed in the same transaction. If not send them one by one.
If the rest of the world is interested in knowing that the customer WAS cleaned app2 would bus.Publish(new CustomerCleanedUpEvent()).
The FullDuplex sample in NServiceBus will show you how to Send and the PubSub sample will demonstrate how to Publish.
Hope this helps!
I would even question the need here for NServiceBus at all. It sounds like you're doing a "data dump". If you are simply moving data around and you don't care about the business reasons why, then a scheduled task or "cron" job will do just fine on the sending and receiving side.
精彩评论