public class ConsumerRecords<P> extends java.lang.Object implements java.lang.Iterable<ConsumerRecord>
ConsumerRecord
. It is returned by
Consumer.poll(long)
. Since it implements Iterable
the SDK user
can iterate using a for structure.Modifier and Type | Field and Description |
---|---|
static ConsumerRecords |
EMPTY
The consumer record instance.
|
Constructor and Description |
---|
ConsumerRecords(java.util.Map<TopicPartition,java.util.List<ConsumerRecord<P>>> records)
Constructor for the consumer record Map.
|
Modifier and Type | Method and Description |
---|---|
int |
count()
Gets total of records contained in the records object instance.
|
static ConsumerRecords |
empty()
Gets an empty set of the consumer records map.
|
boolean |
isEmpty()
Gets a boolean value that checks if the records map if empty.
|
java.util.Iterator<ConsumerRecord> |
iterator() |
java.util.Set<TopicPartition> |
partitions()
Gets the topic partition Set object for the records Map.
|
java.lang.Iterable<ConsumerRecord> |
records(java.lang.String topic)
Gets an Iterable instance of ConsumerRecord list.
|
java.util.List<ConsumerRecord> |
records(TopicPartition partition)
Gets the consumer ConsumerRecord list.
|
public static final ConsumerRecords EMPTY
public ConsumerRecords(java.util.Map<TopicPartition,java.util.List<ConsumerRecord<P>>> records)
records
- a Map that groups a list of records for each Partition.org.apache.commons.lang.NullArgumentException
- when records is null.public static ConsumerRecords empty()
public java.util.List<ConsumerRecord> records(TopicPartition partition)
partition
- The topic partition name to get the partition number.public java.lang.Iterable<ConsumerRecord> records(java.lang.String topic)
topic
- The topic name.public java.util.Set<TopicPartition> partitions()
public java.util.Iterator<ConsumerRecord> iterator()
iterator
in interface java.lang.Iterable<ConsumerRecord>
public int count()
public boolean isEmpty()