You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by David KOCH <dk...@ezakus.com> on 2016/09/01 18:41:07 UTC

Error setting consumer offset using SimpleConsumer#commitOffsets.

Hello,

I am having problems setting the partition offset for a given consumer
group using SimpleConsumer#commitOffsets. I encounter error code "25". Am I
going about this the right way? I am using Kafka 0.10.0. The consumers use
the new API.

Here is a runnable example
<https://gist.github.com/thaDude/788a8b9f95a54d5a88436ad3df5ccf0e>. I
copied the relevant code parts below.

String consumerId = "my-test";
String topic = "my-test-topic";
Long consumerOffset = 5L;
SimpleConsumer consumer = new SimpleConsumer("localhost", 9092, 100000, 64
* 1024, consumerId);

HashMap<TopicAndPartition, OffsetAndMetadata> map = new HashMap<>();
map.put(new TopicAndPartition(topic, 0),
    // No idea what those parameters mean.
    new OffsetAndMetadata(new OffsetMetadata(consumerOffset,
"NO_METADATA"), -1L, -1L));
OffsetCommitRequest offsetCommitReq = new
OffsetCommitRequest("test-consumer-group", map, 0, consumerId,
    kafka.api.OffsetCommitRequest.CurrentVersion());

OffsetCommitResponse response = consumer.commitOffsets(offsetCommitReq);
if (response.hasError()) {
    # Error is code 25.
    System.out.println(response.errorCode(new TopicAndPartition(topic, 0)));
}


Thanks,

David