Class KafkaTopicPartitionsIterator<K,​V>

java.lang.Object
com.markosindustries.distroboy.kafka.KafkaTopicPartitionsIterator<K,​V>
Type Parameters:
K - The type of keys the KafkaConsumer will deserialise
V - The type of values the KafkaConsumer will deserialise
All Implemented Interfaces:
java.util.Iterator<org.apache.kafka.clients.consumer.ConsumerRecord<K,​V>>

public class KafkaTopicPartitionsIterator<K,​V>
extends java.lang.Object
implements java.util.Iterator<org.apache.kafka.clients.consumer.ConsumerRecord<K,​V>>
Provides an Iterator interface to the data in Kafka for a given set of TopicPartitions. Reads from the starting offsets (inclusive) to the ending offsets (exclusive) specified.
  • Constructor Summary

    Constructors
    Constructor Description
    KafkaTopicPartitionsIterator​(org.apache.kafka.clients.consumer.Consumer<K,​V> kafkaConsumer, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions, KafkaOffsetSpec startOffsetsInclusiveSpec, KafkaOffsetSpec endOffsetsExclusiveSpec)  
  • Method Summary

    Modifier and Type Method Description
    boolean hasNext()  
    org.apache.kafka.clients.consumer.ConsumerRecord<K,​V> next()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining, remove
  • Constructor Details

    • KafkaTopicPartitionsIterator

      public KafkaTopicPartitionsIterator​(org.apache.kafka.clients.consumer.Consumer<K,​V> kafkaConsumer, java.util.Collection<org.apache.kafka.common.TopicPartition> topicPartitions, KafkaOffsetSpec startOffsetsInclusiveSpec, KafkaOffsetSpec endOffsetsExclusiveSpec)
      Parameters:
      kafkaConsumer - A KafkaConsumer to communicate with Kafka via
      topicPartitions - The set of TopicPartitions to iterate records from
      startOffsetsInclusiveSpec - The starting offset spec (inclusive)
      endOffsetsExclusiveSpec - The end offset spec (exclusive)
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface java.util.Iterator<K>
    • next

      public org.apache.kafka.clients.consumer.ConsumerRecord<K,​V> next()
      Specified by:
      next in interface java.util.Iterator<K>