Interprocess pubsub without network dependency
Suppose I have no network card installed on my computer, and I would like to have functionality similar to the following:
Process 1 will publish messages to some URI, say "Uri1"
var publisher = new Publisher("Uri1");
publisher.publish(new Message("Somedata");
Process 2 will both listen for messages on "Uri1" and publish messages to "Uri2"
var subscriber = new Subscriber("Uri1")
subscriber.MessageReceived += data => Console.Writeline(data.ToString());
var publisher = new Publisher("Uri2")
publisher.Publish(new Message("SomeMoreData"))
Process 3 will listen for messages from both URIs
var subscriber = new Subscriber("Uri1")
subscriber.MessageReceived += data => Console.Writeline(data.ToString());
var anotherSubscriber = new Subscriber("Uri2")
anotherSubscriber.MessageReceived += data => Console.Writeline(data.ToString());
All processes run on the same computer. After some research I believe MSMQ is the way to go (using queue names as URIs) but the implementation question remains. I came across several possibilities:
Usi开发者_如何学Cng MSMQ directly
The problem I have with this approach is that I would have to manage the queues my self e.g. creation, population, purging... also from what I read I may encounter many pitfalls and limitations of MSMQ seeing as I am not experienced with itUsing NServiceBus, MassTransit or RhinoServiceBus (all use MSMQ) They all seem competent, especially NServiceBus, but I can't seem to figure out from the documentation how to extract the basic pubsub functionality from any of them so that I could encapsulate it in an interface similar to the above
Using WCF(over MSMQ) Again this looks like a good option, but seeing as I am far from a WCF expert I would like to make sure this is the way to go before I start delving into it
Our approach up until now has relied on PGM multicast which worked well enough, but the new requirement of working without a network card forces us to use another mechanism for offline work, at least as far as I know
Thanks!
In the end, we chose a shared memory ready-made solution: http://pubsub.codeplex.com/ Initial testing imply it works well for our case
Well, according to http://answers.yahoo.com/question/index?qid=20080616091430AAAxTJB you can use the loopback address without a NIC installed. Maybe you can use that functionality to continue using your existing code?
Note: I have not tested this, it was just an idea.
精彩评论