[rabbitmq-discuss] Publish-Confirm

cw storm cwstorm at gmail.com
Wed Feb 26 18:37:08 GMT 2014


Thanks MK.  I was just about to say.  Use ch.waitForConfirmsOrDie();
instead, right?


On Wed, Feb 26, 2014 at 1:25 PM, Michael Klishin <
michael.s.klishin at gmail.com> wrote:

>
> 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
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140226/b3601301/attachment.html>


More information about the rabbitmq-discuss mailing list