[zeromq-dev] How many messages are in queue now?
Steve Eley
sfeley at gmail.com
Fri Apr 17 18:42:06 CEST 2015
> On Apr 17, 2015, at 10:00 AM, Ilja Golshtein <ilejncs at narod.ru> wrote:
>
> Agree that it makes perfect sense for multiple producers and consumers, while in my case it is ZMQ_PAIR.
Simple solution for your use case:
Add an incrementing serial number to each of your outgoing messages.
The sending thread keeps track of the last serial number it sent.
The receiving thread keeps track of the last serial number it received.
Periodically, a third thread:
Collects both numbers for the current point in time (via shared variables or sockets, it doesn't matter).
Subtracts last_sent - last_received. The difference is the approximate number of messages in the queue at that moment.
Compares that answer against the HWM and takes whatever action is appropriate.
Does that help?
Have Fun,
Steve Eley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150417/b96b31a4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4877 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150417/b96b31a4/attachment.bin>
More information about the zeromq-dev
mailing list