On Tue, 2020-12-08 at 22:05 +0100, Arnaud Loonstra wrote:
> Hey all,
> 
> I might me missing something but is there any way of detecting messages 
> being dropped due to the high watermark on a PUB socket?
> 
> It's clear how to do this is on a socket that blocks in the mute state, 
> but dropping message on mute is not?
> 
> for example:
> 
> // test hwm
> sock_t *push = zsock_new(ZMQ_PUB);
> zsock_t *pull = zsock_new(ZMQ_SUB);
> zsock_set_rcvhwm(pull, 100);
> zsock_set_sndhwm(push, 100);
> zsock_set_sndtimeo(push,0);
> zsock_bind(push, "inproc://test");
> zsock_connect(pull, "inproc://test");
> zsock_set_subscribe(pull, "");
> zclock_sleep(10);
> int rc = 0;
> int count = 0;
> while( rc == 0 && count < 10000) {
>      rc = zstr_send(push, "BOE");
>      count++;
> }
> 
> The count will be 10000 due zstr_send dropping messages but returning 0;
> If we then receive the buffered messages we wil receive 20 messages 
> (rcvhwm + sndhwm)
> 
> int count2 = 0;
> char *m = "";
> while ( m )
> {
>      char *m = zstr_recv_nowait(pull);
>      count2++;
> }
> 
> Rg,
> 
> Arnaud

There is no deterministic way, and when you think about the conditions
that might cause that to happen, it makes sense that there isn't.

We have added queue stats capability to socket monitors last year,
which will give you some insights - but it's of course asynchronous and
best-effort, and thus useful for debugging and statistics but not for
making logic decisions.
The OS should provide you with data about the state of the underlying
network interfaces/buffers.

-- 
Kind regards,
Luca Boccassi

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to