<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2014-02-26 22:16 GMT+04:00 cw storm <span dir="ltr"><<a href="mailto:cwstorm@gmail.com" target="_blank">cwstorm@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>I'm trying to understand the below snippet:</div><div><br></div><div><pre style="color:rgb(85,85,85);font-size:13px;line-height:18px">for (long i = 0; i < MSG_COUNT; ++i) {
     unconfirmedSet.add(ch.getNextPublishSeqNo());
     ch.basicPublish("", QUEUE_NAME, MessageProperties.PERSISTENT_BASIC,
                       "nop".getBytes());
 }
while (unconfirmedSet.size() > 0)
     Thread.sleep(10);</pre><pre style="color:rgb(85,85,85);font-size:13px;line-height:18px">As stated, "<span style="font-family:Verdana,sans-serif">the producer waits for all the messages to be confirmed."  Assuming that's the above code.  Is the "while" logic safe?  What happens when the "unconfirmedSet.size" is always greater than 0?  Also, the "MSG_COUNT" if set to 10000, does the for loop will always loop 10000 times even though there might only be say 10 messages?</span></pre>

</div></blockquote></div><div class="gmail_extra">That blog post is over 2 years old.</div><br>Consider using Channel#waitForConfirms instead.<br>-- <br>MK<br><br><a href="http://github.com/michaelklishin" target="_blank">http://github.com/michaelklishin</a><br>

<a href="http://twitter.com/michaelklishin" target="_blank">http://twitter.com/michaelklishin</a><br>
</div></div>