public class ConsumerRecords<K,V> extends Object implements Iterable<ConsumerRecord<K,V>>
ConsumerRecord
per partition for a
particular topic. There is one ConsumerRecord
list for every topic
partition returned by a Consumer.poll(java.time.Duration)
operation.Modifier and Type | Field and Description |
---|---|
static ConsumerRecords<Object,Object> |
EMPTY |
Constructor and Description |
---|
ConsumerRecords(Map<TopicPartition,List<ConsumerRecord<K,V>>> records) |
Modifier and Type | Method and Description |
---|---|
int |
count()
The number of records for all topics
|
static <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 topic
|
List<ConsumerRecord<K,V>> |
records(TopicPartition partition)
Get just the records for the given partition
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final ConsumerRecords<Object,Object> EMPTY
public ConsumerRecords(Map<TopicPartition,List<ConsumerRecord<K,V>>> records)
public List<ConsumerRecord<K,V>> records(TopicPartition partition)
partition
- The partition to get records forpublic Iterable<ConsumerRecord<K,V>> records(String topic)
public Set<TopicPartition> partitions()
public Iterator<ConsumerRecord<K,V>> iterator()
iterator
in interface Iterable<ConsumerRecord<K,V>>
public int count()
public boolean isEmpty()
public static <K,V> ConsumerRecords<K,V> empty()