kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Piggott <cpigg...@gmail.com>
Subject Need sample/example of updating offset in SImple Consumer
Date Mon, 09 Feb 2015 23:20:29 GMT
Hi,

Can somebody provide me with an example of how to formulate an
OffsetCommitRequest for a single stream/partition using SimpleConsumer from
java?

Both ends, really ... periodically issuing commits, but also how to get the
current offset when starting up.


I can show what I'm attempting ... but failing to connect the objects and
constructors:


TopicAndPartition key = new TopicAndPartition(topic, shardNum);
OffsetMetadataAndError value = new OffsetMetadataAndError(offset); /* ??? */

Map<TopicAndPartition, OffsetMetadataAndError> map =
Collections.singletonMap(key, value);

OffsetCommitRequest request = new OffsetCommitRequest(
        groupId,
        map,
        kafka.api.OffsetCommitRequest.CurrentVersion(),
        0, /* what do I do with this - correlation id? */
        clientName);

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message