[zeromq-dev] Watermarks & socket types

Martin Sustrik sustrik at 250bpm.com
Tue May 25 10:56:54 CEST 2010


> I'm began developing  of my client-server apps when no xrep/xreq
> sockets was available and ZMQ_HWM/ZMQ_LWM was present, but not
> implemented. My clients are asyncronous (it can send multiple
> request(s) at one time, and then wait for all or some from
> response(s)). When i started developing, the only plausible solution
> was:
> 1) using ZMQ_DOWNSTREAM socket to send request to one from servers,
> and include client ID in request.
> 2) using ZMQ_PUB on server to send responses to topic with client ID
> 3) using ZMQ_SUB socket, subscribed to client ID for receive responses
> As i understand, now zmq has more better solution:
> 1) using ZMQ_XREQ socket on client for sending multiple requests
> without waiting a reply.
> 2) using ZMQ_XREP socket on server.

If you don't mind requester working in lock-step fashion you can use 
REQ/REP. If you have to have multiple request in the air at the same 
time use XREQ/XREP.

> Currently, now my old solution is not working properly, when i use
> watermarks. When i use low values for watermarks, some messages that
> sent to ZMQ_PUB are dropped and not received by ZMQ_SUB. In
> documentation i didn't found detailed information about how watermarks
> works for different socket types (for some types messages will be
> dropped, for other types sending thread will be blocked). Can you get
> detailed info about this?

PUB/SUB = drop the message
otherwise = block the sender

> Is there some workaround to prevent message dropping in my old
> solution when using watermarks, or i must rewrite all this logic to
> ZMQ_XREQ/ZMQ_XREP sockets?

No, sorry. The behaviour in case of full queue is defined by messaging 
pattern, i.e. PUB/SUB => drop messages if queue is full.


More information about the zeromq-dev mailing list