You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Jochen Mader <jo...@codecentric.de> on 2015/02/22 22:16:44 UTC
Commit offset with SimpleConsumer in 0.8.2
I have a hard time figuring out how to do a commit using API 0.8.2 on JDK 8.
I tried using the examples from 0.8.1.1.
First of all: I can't use OffsetMetadataAndError inside the
offsets-map as it was possible in 0.8.1. I can't really find a
difference, but builds break.
I'm also unable to figure out all of the required parameters.
<topic> and <partition> are obviuous.
I suppose the <groupId> is the client-name I picked for my consumer.
But what is the value expected for the <correlationId>?
Here is my code that won't build with 0.8.2 on JDK 8:
Map<TopicAndPartition, OffsetAndMetadata> offsets = new HashMap<>();
offsets.put(new TopicAndPartition(*<topic>*, *<partition>*), new
OffsetMetadataAndError(messageAndOffset.offset(), "",
ErrorMapping.NoError()));
OffsetCommitRequest ocRequest = new OffsetCommitRequest(*<groupId>*,
offsets, *<correlationId>*, consumer.clientId(),
kafka.api.OffsetCommitRequest.CurrentVersion());
OffsetCommitResponse offsetCommitResponse = consumer.commitOffsets(ocRequest);
Thanks,
Jochen
--
Jochen Mader | Lead IT Consultant
codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de |
www.more4fi.de
Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz
Re: Commit offset with SimpleConsumer in 0.8.2
Posted by Jochen Mader <jo...@codecentric.de>.
Thanks for the pointer!!
Added myself as a watcher.
2015-02-24 3:12 GMT+01:00 Joel Koshy <jj...@gmail.com>:
> Can you add yourself as a watcher on KAFKA-1729? I will update that
> when I fix the example on the wiki.
>
> On Sun, Feb 22, 2015 at 10:16:44PM +0100, Jochen Mader wrote:
> > I have a hard time figuring out how to do a commit using API 0.8.2 on
> JDK 8.
> >
> > I tried using the examples from 0.8.1.1.
> >
> > First of all: I can't use OffsetMetadataAndError inside the
> > offsets-map as it was possible in 0.8.1. I can't really find a
> > difference, but builds break.
> >
> > I'm also unable to figure out all of the required parameters.
> >
> > <topic> and <partition> are obviuous.
> >
> > I suppose the <groupId> is the client-name I picked for my consumer.
> >
> > But what is the value expected for the <correlationId>?
> >
> > Here is my code that won't build with 0.8.2 on JDK 8:
> >
> > Map<TopicAndPartition, OffsetAndMetadata> offsets = new HashMap<>();
> >
> > offsets.put(new TopicAndPartition(*<topic>*, *<partition>*), new
> > OffsetMetadataAndError(messageAndOffset.offset(), "",
> > ErrorMapping.NoError()));
> >
> > OffsetCommitRequest ocRequest = new OffsetCommitRequest(*<groupId>*,
> > offsets, *<correlationId>*, consumer.clientId(),
> > kafka.api.OffsetCommitRequest.CurrentVersion());
> > OffsetCommitResponse offsetCommitResponse =
> consumer.commitOffsets(ocRequest);
> >
> >
> > Thanks,
> > Jochen
> > --
> > Jochen Mader | Lead IT Consultant
> >
> > codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
> > tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
> > www.codecentric.de | blog.codecentric.de | www.meettheexperts.de |
> > www.more4fi.de
> >
> > Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
> > Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
> > Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen
> Schütz
>
>
--
Jochen Mader | Lead IT Consultant
codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de |
www.more4fi.de
Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz
Re: Commit offset with SimpleConsumer in 0.8.2
Posted by Joel Koshy <jj...@gmail.com>.
Can you add yourself as a watcher on KAFKA-1729? I will update that
when I fix the example on the wiki.
On Sun, Feb 22, 2015 at 10:16:44PM +0100, Jochen Mader wrote:
> I have a hard time figuring out how to do a commit using API 0.8.2 on JDK 8.
>
> I tried using the examples from 0.8.1.1.
>
> First of all: I can't use OffsetMetadataAndError inside the
> offsets-map as it was possible in 0.8.1. I can't really find a
> difference, but builds break.
>
> I'm also unable to figure out all of the required parameters.
>
> <topic> and <partition> are obviuous.
>
> I suppose the <groupId> is the client-name I picked for my consumer.
>
> But what is the value expected for the <correlationId>?
>
> Here is my code that won't build with 0.8.2 on JDK 8:
>
> Map<TopicAndPartition, OffsetAndMetadata> offsets = new HashMap<>();
>
> offsets.put(new TopicAndPartition(*<topic>*, *<partition>*), new
> OffsetMetadataAndError(messageAndOffset.offset(), "",
> ErrorMapping.NoError()));
>
> OffsetCommitRequest ocRequest = new OffsetCommitRequest(*<groupId>*,
> offsets, *<correlationId>*, consumer.clientId(),
> kafka.api.OffsetCommitRequest.CurrentVersion());
> OffsetCommitResponse offsetCommitResponse = consumer.commitOffsets(ocRequest);
>
>
> Thanks,
> Jochen
> --
> Jochen Mader | Lead IT Consultant
>
> codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
> tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
> www.codecentric.de | blog.codecentric.de | www.meettheexperts.de |
> www.more4fi.de
>
> Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
> Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
> Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz