You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by shahab <sh...@gmail.com> on 2015/08/28 10:07:10 UTC
Example of "Offset Commit" suing SimpleConsumer API?
Hi,
I do appreciate if someone point me to any java example showing how one
can implement offset commit using Simple Consumer API? I have not found
any !
best,
/Shahab
Re: Example of "Offset Commit" suing SimpleConsumer API?
Posted by shahab <sh...@gmail.com>.
Thanks Erik, yes it was not so difficult. I finally made it working.
best,
/Shahab
On Fri, Aug 28, 2015 at 3:30 PM, Helleren, Erik <Er...@cmegroup.com>
wrote:
> Shahab,
> So, after a few searches, it just makes sense to paste it here. To Commit,
> do something like this:
> OffsetCommitRequest request = new OffsetCommitRequest(StringgroupId,
> Map<TopicAndPartition, OffsetAndMetadata> requestInfo, int correlationId,
> String clientId, short versionId);
> simpleConsumer.commitOffsets(request);
>
>
> I am leaving the full constructor header so you know the data typesÅ And
> some code to read the offsets:
> OffsetFetchRequest request = new OffsetFetchRequest(String groupId,
> List<TopicAndPartition> requestInfo, short versionId, int correlationId,
> String clientId);
> Map<TopicAndPartition,OffsetMetadataAndError> offsets=
> simpleConsumer.fetchOffsets(request).offsets();
>
> Please read the java docs for the offsetCommit and OffsetFetch for what
> each of their parameters mean. But its relatively straightforward.
> -Erik
>
>
>
> On 8/28/15, 3:07 AM, "shahab" <sh...@gmail.com> wrote:
>
> >Hi,
> >
> >I do appreciate if someone point me to any java example showing how one
> >can implement offset commit using Simple Consumer API? I have not found
> >any !
> >
> >
> >best,
> >/Shahab
>
>
Re: Example of "Offset Commit" suing SimpleConsumer API?
Posted by "Helleren, Erik" <Er...@cmegroup.com>.
Shahab,
So, after a few searches, it just makes sense to paste it here. To Commit,
do something like this:
OffsetCommitRequest request = new OffsetCommitRequest(StringgroupId,
Map<TopicAndPartition, OffsetAndMetadata> requestInfo, int correlationId,
String clientId, short versionId);
simpleConsumer.commitOffsets(request);
I am leaving the full constructor header so you know the data typesÅ And
some code to read the offsets:
OffsetFetchRequest request = new OffsetFetchRequest(String groupId,
List<TopicAndPartition> requestInfo, short versionId, int correlationId,
String clientId);
Map<TopicAndPartition,OffsetMetadataAndError> offsets=
simpleConsumer.fetchOffsets(request).offsets();
Please read the java docs for the offsetCommit and OffsetFetch for what
each of their parameters mean. But its relatively straightforward.
-Erik
On 8/28/15, 3:07 AM, "shahab" <sh...@gmail.com> wrote:
>Hi,
>
>I do appreciate if someone point me to any java example showing how one
>can implement offset commit using Simple Consumer API? I have not found
>any !
>
>
>best,
>/Shahab