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