[rabbitmq-discuss] Publish-Confirm
Michael Klishin
michael.s.klishin at gmail.com
Wed Feb 26 18:25:49 GMT 2014
2014-02-26 22:16 GMT+04:00 cw storm <cwstorm at gmail.com>:
> I'm trying to understand the below snippet:
>
> 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);
>
> As stated, "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?
>
> That blog post is over 2 years old.
Consider using Channel#waitForConfirms instead.
--
MK
http://github.com/michaelklishin
http://twitter.com/michaelklishin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140226/c6e9ad44/attachment.html>
More information about the rabbitmq-discuss
mailing list