What if instead of sending from the tail, you just used a push socket that the head could wait on in a loop. The REP socket could send a reply to the client immediately after having received from the tail on a pull socket. In this way, you still get what you want, and don't have to deal with the idea of maintaining addresses to send to the tail in order that they be sent to the right destination.
Another cool idea that might be of interest to you is the idea that mutiple requests can be concurrently processed in the chain, with the head accepting and forwarding as many as can be read on the socket. In this way, the entire system isn't waiting as I implied above; you have higher throughput this way, because that's less time spent doing nothing but waiting. In any case, I think the way to do this would be to use a router socket at the head, and forward the address from the original client around through your chain. When that address gets back use it to send on the router socket. On Fri, Mar 6, 2015 at 11:47 AM, Larry White <[email protected]> wrote: > Hi, > > I'm trying to implement "chain replication" using 0MQ, and need help > configuring the system. > > In chain replication, you have n clients and a sequence of server > replicas. The replicas are updated in order from HEAD to TAIL. A three > link chain works in a loop like this: > > 1. CLIENT sends write request to HEAD > 2. HEAD processes request and forwards to MIDDLE (No reply to client) > 3. MIDDLE processes request and forwards to TAIL > 4. TAIL processes request and sends a reply back to CLIENT. > > I would like the interaction between CLIENT and the chain to be > synchronous (blocking), so that the client waits until it receives the > reply from TAIL. > > I tried to set this up with head having a REP socket for client and a PUSH > socket for the chain. This causes an exception (obvious in hindsight) that > says > > java.lang.IllegalStateException: Cannot receive another request > > What is the correct way to do structure the relationship between Client > and Head? > > Thank you very much for your help. > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > >
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
