kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ewen Cheslack-Postava" ...@ewencp.org>
Subject Re: Does adding ConsumerTimeoutException make the code more robust?
Date Mon, 01 Dec 2014 17:56:00 GMT
No, hasNext will return immediately if data is available. The consumer
timeout is only helpful if your application can't safely block on the
iterator indefinitely.

-Ewen

On Sat, Nov 29, 2014, at 08:35 PM, Rahul Amaram wrote:
> Yes, I have configured consumer timeout config.
> 
> Let me put my query other way. Is it possible that it.hasNext() could be 
> blocked even when there are messages available, In which case using 
> Consumer Timeout could help?
> 
> Thanks,
> Rahul.
> 
> On Saturday 29 November 2014 09:56 PM, Jun Rao wrote:
> > By default, it.hasNext() blocks when there is no more message to consume.
> > So catching ConsumerTimeoutException doesn't make any difference. You only
> > need to handle ConsumerTimeoutException if you have customized the consumer
> > timeout config.
> >
> > Thanks,
> >
> > Jun
> >
> > On Thu, Nov 27, 2014 at 7:48 AM, Rahul Amaram <rahul.amaram@vizury.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I am just wondering if the below snippet
> >>
> >> ConsumerIterator<byte[], byte[]) it = ...
> >>
> >> while (True)
> >>      try {
> >>          while (it.hasNext()) {
> >>          ...
> >>          ...
> >>          ...
> >>      } catch (ConsumerTimeoutException e) {
> >>          // do nothing
> >>      }
> >> }
> >>
> >> would be more robust than
> >>
> >> while(it.hasNext()) {
> >> ...
> >> ...
> >> ...
> >> }
> >>
> >> i.e. by setting a consumer timeout, catching it and again just waiting for
> >> the next message make it more robust?
> >>
> >> Regards,
> >> Rahul.
> >>
> 

Mime
View raw message