<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 03/11/14 13:58, 张顺通 wrote:<br>
    </div>
    <blockquote
cite="mid:CA+igrvx5NP40CWhYZn6udA5QbCdr3vHMRvXBAYm_phzg34ZKEg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>whle (mq_fetch("QUEUE")) {<br>
          </div>
             if (yes) {<br>
        </div>
             do something<br>
        <div>  } else {<br>
               mq_add("QUEUE");<br>
        </div>
        <div>    add back to queue.<br>
        </div>
        <div>  }<br>
        </div>
        <div>
          <div>}<br>
            <br>
          </div>
          <div>can mq_add use here? I tried it, it do not work.<br>
          </div>
          <div>and <span
style="color:rgb(67,67,67);font-family:Arial,sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:24px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none">How
              to determine the end?</span></div>
        </div>
      </div>
      <br>
    </blockquote>
    it should work to add back to the queue from same loop, but then
    practically you get infinite loop until the queue gets empty.<br>
    <br>
    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).<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio Advanced Training, Nov 24-27, Berlin - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
  </body>
</html>