Great thanks!

On Mon, Aug 10, 2015 at 7:03 PM, Ewen Cheslack-Postava <e...@confluent.io>
wrote:

> Right now I think the only place the new API is documented is in the
> javadocs. Here are the relevant sections for replacing the simple consumer.
>
> Subscribing to specific partitions:
>
> https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L204
> Seeking to specific partitions:
>
> https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L282
>
> With the new API you'll just need to do something like this:
>
> TopicPartition tp = new TopicPartition("topic", 1);
> long offset = 100;
>
> KafkaConsumer consumer = new KafkaConsumer<Object,Object>(props);
> consumer.subscribe(tp);
> consumer.seek(tp, offset);
> while(true) {
>    ConsumerRecords records = consumer.poll();
>    if (!records.isEmpty()) {
>       // records[0] will be the message you wanted
>       break;
>    }
> }
>
>
>
> On Mon, Aug 10, 2015 at 3:52 PM, Joe Lawson <
> jlaw...@opensourceconnections.com> wrote:
>
> > Ewen,
> >
> > Do you have an example or link for the changes/plans that will bring the
> > benefits you describe?
> >
> > Cheers,
> >
> > Joe Lawson
> > On Aug 10, 2015 3:27 PM, "Ewen Cheslack-Postava" <e...@confluent.io>
> > wrote:
> >
> > > You can do this using the SimpleConsumer. See
> > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example
> > > for details with some code.
> > >
> > > When the new consumer is released in 0.8.3, this will get a *lot*
> > simpler.
> > >
> > > -Ewen
> > >
> > > On Fri, Aug 7, 2015 at 9:26 AM, Padgett, Ben <bpadg...@illumina.com>
> > > wrote:
> > >
> > > > Does anyone have an example of how to get a single record from a
> > > > topic+partition given a specific offset?
> > > >
> > > > I am interested in this for some retry logic for failed messages.
> > > >
> > > > Thanks!
> > > >
> > > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Reply via email to