[zeromq-dev] 0MQ 2.0 Model Question

Martin Sustrik sustrik at fastmq.com
Thu Oct 8 11:23:15 CEST 2009

> but what is the advantage of using 0MQ in the req/rep model then ? using 
> normal sockets i can also make sure that the message is received by 
> waiting of an 'ack'.  are there any other messaging models on the 
> drawing board that might be implemented ?

The most functionality is on the replier side. Instead of handling 10000 
connections being created and dropping of asynchronously, sending 
requests and waiting for replies, all you have to do is:

socket_t s (ctx, ZMQ_REP);
s.bind ("tcp://eth0:5555");
while (true) {
     message_t request, reply;
     s.recv (&request);
     ... process the request ...
     s.send (reply);

NB that this code is handling many simultaneous connections not only a 
single pair of peers.

As for reliability, there are some advantages there (like setting a 
connection identity so that when reconnection happens, the system knows 
it's the 'same' connection and handles the queue limits and other 
associated issues accordingly). However, these features are not fully 
implemented so I'm not going to detail here.


More information about the zeromq-dev mailing list