You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Vadim Keylis <vk...@gmail.com> on 2014/03/01 00:18:38 UTC

Fetch Response for invalid offset returns success.

Good afternoon. I am writing my own client that is based on simple
consumer. I implemented method that is based on example in the kafka
documents that sends request to kafka to find an offset. I am trying to
find offsets after given offset. The api returns success even those offset
does not exist but offsets array has length of 0. What is the right way to
find next valid offset if the one been passed not found in Kafka.

Thanks,
Vadim

Re: Fetch Response for invalid offset returns success.

Posted by Vadim Keylis <vk...@gmail.com>.
I am using Kafka 0.8


On Fri, Feb 28, 2014 at 4:30 PM, Neha Narkhede <ne...@gmail.com>wrote:

> What version of Kafka are you using?
>
>
> On Fri, Feb 28, 2014 at 3:18 PM, Vadim Keylis <vk...@gmail.com>
> wrote:
>
> > Good afternoon. I am writing my own client that is based on simple
> > consumer. I implemented method that is based on example in the kafka
> > documents that sends request to kafka to find an offset. I am trying to
> > find offsets after given offset. The api returns success even those
> offset
> > does not exist but offsets array has length of 0. What is the right way
> to
> > find next valid offset if the one been passed not found in Kafka.
> >
> > Thanks,
> > Vadim
> >
>

Re: Fetch Response for invalid offset returns success.

Posted by Neha Narkhede <ne...@gmail.com>.
What version of Kafka are you using?


On Fri, Feb 28, 2014 at 3:18 PM, Vadim Keylis <vk...@gmail.com> wrote:

> Good afternoon. I am writing my own client that is based on simple
> consumer. I implemented method that is based on example in the kafka
> documents that sends request to kafka to find an offset. I am trying to
> find offsets after given offset. The api returns success even those offset
> does not exist but offsets array has length of 0. What is the right way to
> find next valid offset if the one been passed not found in Kafka.
>
> Thanks,
> Vadim
>

Re: Fetch Response for invalid offset returns success.

Posted by Jun Rao <ju...@gmail.com>.
You may have mis-understood the api. getOffsetsBefore() returns a valid
offset before a given timestamp, not a given offset.

Thanks,

Jun


On Fri, Feb 28, 2014 at 5:02 PM, Vadim Keylis <vk...@gmail.com> wrote:

> Hello Guozhang. The following is slightly modified version of the example.
> Where offset can be previously valid offset, but does not exist in kafka
> for one or the other valid reason.
> TopicAndPartition topicAndPartition = new TopicAndPartition(topic,
> partition);
>         Map<TopicAndPartition, PartitionOffsetRequestInfo> requestInfo =
> new HashMap<TopicAndPartition, PartitionOffsetRequestInfo>();
>         requestInfo.put(topicAndPartition, new
> PartitionOffsetRequestInfo(offset, 1));
>         kafka.javaapi.OffsetRequest request = new
> kafka.javaapi.OffsetRequest(
>                 requestInfo, (short) requiestedOffset,
> config.getGroupId());
>         OffsetResponse response = simpleConsumer.getOffsetsBefore(request);
>
>         if (response.hasError()) {
>                return;
>         }
>
>         long[] offsets = response.offsets(topic, partition);
>
>
>
>
> On Fri, Feb 28, 2014 at 4:36 PM, Guozhang Wang <wa...@gmail.com> wrote:
>
> > Hi Vadim,
> >
> > Which example in the kafka doc are you following?
> >
> > Guozhang
> >
> >
> > On Fri, Feb 28, 2014 at 3:18 PM, Vadim Keylis <vk...@gmail.com>
> > wrote:
> >
> > > Good afternoon. I am writing my own client that is based on simple
> > > consumer. I implemented method that is based on example in the kafka
> > > documents that sends request to kafka to find an offset. I am trying to
> > > find offsets after given offset. The api returns success even those
> > offset
> > > does not exist but offsets array has length of 0. What is the right way
> > to
> > > find next valid offset if the one been passed not found in Kafka.
> > >
> > > Thanks,
> > > Vadim
> > >
> >
> >
> >
> > --
> > -- Guozhang
> >
>

Re: Fetch Response for invalid offset returns success.

Posted by Vadim Keylis <vk...@gmail.com>.
Hello Guozhang. The following is slightly modified version of the example.
Where offset can be previously valid offset, but does not exist in kafka
for one or the other valid reason.
TopicAndPartition topicAndPartition = new TopicAndPartition(topic,
partition);
        Map<TopicAndPartition, PartitionOffsetRequestInfo> requestInfo =
new HashMap<TopicAndPartition, PartitionOffsetRequestInfo>();
        requestInfo.put(topicAndPartition, new
PartitionOffsetRequestInfo(offset, 1));
        kafka.javaapi.OffsetRequest request = new
kafka.javaapi.OffsetRequest(
                requestInfo, (short) requiestedOffset, config.getGroupId());
        OffsetResponse response = simpleConsumer.getOffsetsBefore(request);

        if (response.hasError()) {
               return;
        }

        long[] offsets = response.offsets(topic, partition);




On Fri, Feb 28, 2014 at 4:36 PM, Guozhang Wang <wa...@gmail.com> wrote:

> Hi Vadim,
>
> Which example in the kafka doc are you following?
>
> Guozhang
>
>
> On Fri, Feb 28, 2014 at 3:18 PM, Vadim Keylis <vk...@gmail.com>
> wrote:
>
> > Good afternoon. I am writing my own client that is based on simple
> > consumer. I implemented method that is based on example in the kafka
> > documents that sends request to kafka to find an offset. I am trying to
> > find offsets after given offset. The api returns success even those
> offset
> > does not exist but offsets array has length of 0. What is the right way
> to
> > find next valid offset if the one been passed not found in Kafka.
> >
> > Thanks,
> > Vadim
> >
>
>
>
> --
> -- Guozhang
>

Re: Fetch Response for invalid offset returns success.

Posted by Guozhang Wang <wa...@gmail.com>.
Hi Vadim,

Which example in the kafka doc are you following?

Guozhang


On Fri, Feb 28, 2014 at 3:18 PM, Vadim Keylis <vk...@gmail.com> wrote:

> Good afternoon. I am writing my own client that is based on simple
> consumer. I implemented method that is based on example in the kafka
> documents that sends request to kafka to find an offset. I am trying to
> find offsets after given offset. The api returns success even those offset
> does not exist but offsets array has length of 0. What is the right way to
> find next valid offset if the one been passed not found in Kafka.
>
> Thanks,
> Vadim
>



-- 
-- Guozhang