A ready to use implementation of broker (mediator) based communication
I am not sure how to formulate the question correctly, so if there are better ideas - go ahead and suggest them.
The problem is simple. I have 2 peers A and B, both behind firewalls. I wish them to communicate with each other using a public broker or mediator, whichever name suits better.
The communication is asynchronous and goes something like this:
- Both A and B periodically poll the broker asking whether there are messages for them.
- When A wishes to communicate with B it sends a message to the broker, indicating that the message is for B.
- When B polls the broker, the broker sees that there is indeed a message for it and respo开发者_如何学运维nds accordingly.
- B processes the messages and sends the response back to the broker, indicating that this is a response to the particular message from A.
- At some point A polls the broker and receives back the response from B.
Now, before I rush in and implement this sort of communication myself, I am wondering whether there are ready to use packages that allow for this sort of communication out of the box.
Anyone?
Thanks.
EDIT1
I wish to emphasize that a peer may not have a message server installed on it. Meaning, simulating request-response with two one-way connections is not possible. I really need to be able to get a reply to peer's response, so it cannot be one-way communication.
EDIT2
One more constraint is that only HTTP(S) ports may be open for the communication, so the agents A and B may be in a situation where they communicate to the broker using HTTP(S) only.
any esb wold do? For instance http://www.nservicebus.com/, or more lightweight: http://www.zeromq.org/
You can make this trivially (IMO) using any HTTPS stack. The architecture of your broker depends on the volume and concurrency you need to handle. Create a resource model such that your applications can PUT and GET messages, where the URI contains the destination node, and add a parameter for a reply address. It should take you about 1 day to figure out a working resource model, 4 hours to code it up. If you need volume, take a server like mongrel2 which has a zeromq backend. Or node.js, which should do this admirably.
ZeroMQ is ideal for building concurrent apps but it's not a HTTP/S service, that's better handed by dedicated front-ends like mongrel2.
Such broker exists as part of AppFabric in Azure platform. In AppFabric you can use Service bus which allows such relayed communication. But you have to pay fees when using it.
精彩评论