[SR-Users] how to use mqueue.

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 5 14:11:40 CET 2014


Hello,

On 03/11/14 13:58, 张顺通 wrote:
> whle (mq_fetch("QUEUE")) {
>    if (yes) {
>      do something
>   } else {
>      mq_add("QUEUE");
>     add back to queue.
>   }
> }
>
> can mq_add use here? I tried it, it do not work.
> and How to determine the end?
>
it should work to add back to the queue from same loop, but then
practically you get infinite loop until the queue gets empty.

There is a function that returns the size of the queue -- mq_size() --
see the readme of the module. Then you can use a variable to increment
as you fetch and exit the while loop when you reach the size. You should
use the latest branch 4.2, as I just reviewed the mq_size() and had an
issue when the queue was empty (0 cannot be a return code for a function
in kamailio.cfg, so now it returns -1 if the queue is empty).

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio Advanced Training, Nov 24-27, Berlin - http://www.asipto.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20141105/1526bf95/attachment.html>


More information about the sr-users mailing list