Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Kafka, mail # user - Fetch Response for invalid offset returns success.


Copy link to this message
-
Re: Fetch Response for invalid offset returns success.
Vadim Keylis 2014-03-01, 01:03
Hello Guozhang. The following is slightly modified version of the example.
Where offset can be previously valid offset, but does not exist in kafka
for one or the other valid reason.
TopicAndPartition topicAndPartition = new TopicAndPartition(topic,
partition);
        Map<TopicAndPartition, PartitionOffsetRequestInfo> requestInfo =
new HashMap<TopicAndPartition, PartitionOffsetRequestInfo>();
        requestInfo.put(topicAndPartition, new
PartitionOffsetRequestInfo(offset, 1));
        kafka.javaapi.OffsetRequest request = new
kafka.javaapi.OffsetRequest(
                requestInfo, (short) requiestedOffset, config.getGroupId());
        OffsetResponse response = simpleConsumer.getOffsetsBefore(request);

        if (response.hasError()) {
               return;
        }

        long[] offsets = response.offsets(topic, partition);
On Fri, Feb 28, 2014 at 4:36 PM, Guozhang Wang <[EMAIL PROTECTED]> wrote: