[zeromq-dev] Hints about async pattern

Chuck Remes lists at chuckremes.com
Mon Apr 9 18:42:10 CEST 2012

On Apr 9, 2012, at 9:11 AM, Marco Trapanese wrote:

> Hello,
> I'm playing with nzmqt on a simple application.
> There are one router and a dozen of dealers. For each dealer I set its 
> own identity, thus I can send async data in both directions.

Setting an identity has *no* impact on being able to send data asynchronously. The two issues (identity and asynchronous send/recv) are not related.

> It works fine, but now the router needs to know which clients are 
> currently connected.
> I periodically send a "ping" message [1]: if I receive a "pong" answer I 
> assume it's alive. If it isn't the router will queue all non-dispatched 
> messages.
> I read the documentation and I'm aware I could use the HWM option to 
> limit the queue size.
> The best setting for the ping purpose is 1, which guarantees that only 
> the most current ping will be answered. But this practice is discouraged 
> in the guide. In fact it limits and slows down everything.
> What do you recommend?

I recommend following this approach:


By using a credit-based flow control mechanism you wouldn't need to worry about pings and pongs to limit the queue size. You could limit by message count or by byte count depending on how you implemented the flow control.


More information about the zeromq-dev mailing list