[zeromq-dev] malamute with zloop reactor

Miao Lin miaolin71 at gmail.com
Thu Aug 13 11:48:05 CEST 2015


Hi:

   I am using malamute client with zloop reactor. my program always stop
receive message after working good for a while.

I checked the verbose out of zloop, seems data consumed too slow. in my
zloop callback function, I only receive one zmsg_t per callback ,does this
correct?

   If no, how to know if there still have message can be read so I can call
mlm_client_recv() many times without block the callback?


Best
Miao


here is the code:


static int s_consumer_event(zloop_t *loop, zsock_t *handle, void *arg)
{
        zmsg_t* m = mlm_client_recv(consumer);
if (NULL == m) {
zsys_info("Invalid NULL zmsg");
return -1;
}

        while (1){
zframe_t* f = zmsg_pop(m);
if (f){
                      ...do some works here....
zframe_destroy(&f);
               }
else
break;
}

zmsg_destroy(&m);

return 0;

}



main(){
....
rc = mlm_client_set_consumer(consumer, dahdi_mlm_event_stream, ".");
assert(rc >= 0);

// create zloop
zloop_t* loop = zloop_new()
assert(loop);

// add consumer to loop
rc = zloop_reader(loop, mlm_client_msgpipe(consumer), s_consumer_event,
NULL);
assert(rc == 0);

// add a timer;
timer_id = zloop_timer(loop, 1000, 0, s_timer_event, NULL);
assert(timer_id != -1);

puts(PRODUCT);
puts(COPYRIGHT);

// handle messages
zloop_start(loop);
....
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150813/053b1c07/attachment.htm>


More information about the zeromq-dev mailing list