I'm trying to figure out the best way to set this up in 0mq and I'm not quite sure which architectural choice is best. I'd love to get some advice.
I'm building a system consisting of a server process on a well known machine (ie with a known domain or ip address) and one or more client processes that can be on home computers, so they may be on connections without a known or constant ip address, behind firewalls, etc. My server process must asynchronously communicate with my clients. These server-to-client broadcasts may occur only a couple of times per day, but the client must process this message instantly and perform some actions on the client computer instantly. Furthermore, the client must respond instantly to the server to acknowledge that the client has received and processed this specific message. As an example, think of a trading advisory system that sends out buy/sell trade signals. No one knows in advance when the server will send these signals (the signals depend on current market conditions), but when the server computes that a signal must be sent, it sends it and the client computers must process these trade signals instantly on their end, say by executing trades on the client's account. So here is the problem. This is not a normal client/server REQ/REP model where the client initiates conversations. It is the server that needs to initiate the conversation (send messages asynchronously). But the client does not have a known IP address for the server to bind to. Furthermore, this is not a PUB/SUB model because the subscriber (the client) must respond back to the server to tell the server that it received this specific message. So there are two possible ways I can implement this. The first way is to have a client/server model where the client sends short data requests constantly, perhaps several times per second. The client is essentially blasting the server with "is there any data yet" messages and the server is constantly replying "no, no, no". A couple of times a day the server will have an actual response "yes here is some real data" and then will expect the server to acknowledge receipt of that real data. This seems like a waste of bandwidth to me. A second approach would be to use two sockets. One is a PUB/SUB socket where the server sends out its twice a day messages and the client gets those messages over a SUB socket. Since the client cannot respond over that sub socket, there is a second REQ/REP socket set up. When the client gets its SUB message, it then sends an acknowledgement over the REQ socket back to the server. This seems like it would work, but I'm not convinced it is the most elegant approach. Is there a more elegant solution to this problem in ZeroMQ? ---------------------------------------------------------------------------- ------ Marc Ilgen [email protected] _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
