You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Mark Horton <ma...@nostromo.net> on 2019/02/04 17:27:17 UTC
poll() question
This is a theoretical question. I have not seen this behavior but
wanted to know if it was possible.
If consumer.poll() returns EMPTY, does that always mean no records are
currently available? In other words, let's say there are some records
in a partition. Could poll() return EMPTY if there was a network
problem that caused it to timeout before it could return that record?
Mark
Re: poll() question
Posted by Pere Urbón Bayes <pe...@gmail.com>.
Hi,
the polls method works with an internal buffer, on a timeout it will
return records in the internal buffers, not necessary from the
topic/partition in the broker.
Missatge de Mark Anderson <ma...@gmail.com> del dia dl., 4 de febr.
2019 a les 19:57:
> I'm sure I initially made this assumption when trying to read all records
> from a compacted topic on application startup and it was incorrect.
>
> Due to latency, threading GC pauses etc it would return 0 when there were
> still records on the topic.
>
> Mark
>
> On Mon, 4 Feb 2019, 18:02 Pere Urbón Bayes <pere.urbon@gmail.com wrote:
>
> > Hi,
> > see from the javadocs:
> >
> > > timeout - The time, in milliseconds, spent waiting in poll if data is
> not
> > available in the buffer. If 0, returns immediately with any records that
> > are available currently in the buffer, else returns empty. Must not be
> > negative.
> >
> > for a network problem it will return an exception.
> >
> > I hope it helps,
> >
> > -- Pere
> >
> >
> >
> > Missatge de Mark Horton <ma...@nostromo.net> del dia dl., 4 de febr.
> 2019 a
> > les 18:27:
> >
> > > This is a theoretical question. I have not seen this behavior but
> > > wanted to know if it was possible.
> > >
> > > If consumer.poll() returns EMPTY, does that always mean no records are
> > > currently available? In other words, let's say there are some records
> > > in a partition. Could poll() return EMPTY if there was a network
> > > problem that caused it to timeout before it could return that record?
> > >
> > > Mark
> > >
> >
> >
> > --
> > Pere Urbon-Bayes
> > Software Architect
> > http://www.purbon.com
> > https://twitter.com/purbon
> > https://www.linkedin.com/in/purbon/
> >
>
--
Pere Urbon-Bayes
Software Architect
http://www.purbon.com
https://twitter.com/purbon
https://www.linkedin.com/in/purbon/
Re: poll() question
Posted by Mark Anderson <ma...@gmail.com>.
I'm sure I initially made this assumption when trying to read all records
from a compacted topic on application startup and it was incorrect.
Due to latency, threading GC pauses etc it would return 0 when there were
still records on the topic.
Mark
On Mon, 4 Feb 2019, 18:02 Pere Urbón Bayes <pere.urbon@gmail.com wrote:
> Hi,
> see from the javadocs:
>
> > timeout - The time, in milliseconds, spent waiting in poll if data is not
> available in the buffer. If 0, returns immediately with any records that
> are available currently in the buffer, else returns empty. Must not be
> negative.
>
> for a network problem it will return an exception.
>
> I hope it helps,
>
> -- Pere
>
>
>
> Missatge de Mark Horton <ma...@nostromo.net> del dia dl., 4 de febr. 2019 a
> les 18:27:
>
> > This is a theoretical question. I have not seen this behavior but
> > wanted to know if it was possible.
> >
> > If consumer.poll() returns EMPTY, does that always mean no records are
> > currently available? In other words, let's say there are some records
> > in a partition. Could poll() return EMPTY if there was a network
> > problem that caused it to timeout before it could return that record?
> >
> > Mark
> >
>
>
> --
> Pere Urbon-Bayes
> Software Architect
> http://www.purbon.com
> https://twitter.com/purbon
> https://www.linkedin.com/in/purbon/
>
Re: poll() question
Posted by Pere Urbón Bayes <pe...@gmail.com>.
Hi,
see from the javadocs:
> timeout - The time, in milliseconds, spent waiting in poll if data is not
available in the buffer. If 0, returns immediately with any records that
are available currently in the buffer, else returns empty. Must not be
negative.
for a network problem it will return an exception.
I hope it helps,
-- Pere
Missatge de Mark Horton <ma...@nostromo.net> del dia dl., 4 de febr. 2019 a
les 18:27:
> This is a theoretical question. I have not seen this behavior but
> wanted to know if it was possible.
>
> If consumer.poll() returns EMPTY, does that always mean no records are
> currently available? In other words, let's say there are some records
> in a partition. Could poll() return EMPTY if there was a network
> problem that caused it to timeout before it could return that record?
>
> Mark
>
--
Pere Urbon-Bayes
Software Architect
http://www.purbon.com
https://twitter.com/purbon
https://www.linkedin.com/in/purbon/