Class ConsumerRecords<K,V>
- java.lang.Object
-
- org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
-
- All Implemented Interfaces:
Iterable<ConsumerRecord<K,V>>
public class ConsumerRecords<K,V> extends Object implements Iterable<ConsumerRecord<K,V>>
A container that holds the listConsumerRecord
per partition for a particular topic. There is oneConsumerRecord
list for every topic partition returned by aConsumer.poll(java.time.Duration)
operation.
-
-
Field Summary
Fields Modifier and Type Field Description static ConsumerRecords<Object,Object>
EMPTY
-
Constructor Summary
Constructors Constructor Description ConsumerRecords(Map<TopicPartition,List<ConsumerRecord<K,V>>> records)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
count()
The number of records for all topicsstatic <K,V>
ConsumerRecords<K,V>empty()
boolean
isEmpty()
Iterator<ConsumerRecord<K,V>>
iterator()
Set<TopicPartition>
partitions()
Get the partitions which have records contained in this record set.Iterable<ConsumerRecord<K,V>>
records(String topic)
Get just the records for the given topicList<ConsumerRecord<K,V>>
records(TopicPartition partition)
Get just the records for the given partition-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
EMPTY
public static final ConsumerRecords<Object,Object> EMPTY
-
-
Constructor Detail
-
ConsumerRecords
public ConsumerRecords(Map<TopicPartition,List<ConsumerRecord<K,V>>> records)
-
-
Method Detail
-
records
public List<ConsumerRecord<K,V>> records(TopicPartition partition)
Get just the records for the given partition- Parameters:
partition
- The partition to get records for
-
records
public Iterable<ConsumerRecord<K,V>> records(String topic)
Get just the records for the given topic
-
partitions
public Set<TopicPartition> partitions()
Get the partitions which have records contained in this record set.- Returns:
- the set of partitions with data in this record set (may be empty if no data was returned)
-
iterator
public Iterator<ConsumerRecord<K,V>> iterator()
-
count
public int count()
The number of records for all topics
-
isEmpty
public boolean isEmpty()
-
empty
public static <K,V> ConsumerRecords<K,V> empty()
-
-