public class ConsumerRecord<K,V> extends Object
Modifier and Type | Field and Description |
---|---|
static long |
NO_TIMESTAMP |
static int |
NULL_CHECKSUM
Deprecated.
checksums are no longer exposed by this class, this constant will be removed in Apache Kafka 4.0
(deprecated since 3.0).
|
static int |
NULL_SIZE |
Constructor and Description |
---|
ConsumerRecord(String topic,
int partition,
long offset,
K key,
V value)
Creates a record to be received from a specified topic and partition (provided for
compatibility with Kafka 0.9 before the message format supported timestamps and before
serialized metadata were exposed).
|
ConsumerRecord(String topic,
int partition,
long offset,
long timestamp,
org.apache.kafka.common.record.TimestampType timestampType,
int serializedKeySize,
int serializedValueSize,
K key,
V value,
Headers headers,
Optional<Integer> leaderEpoch)
Creates a record to be received from a specified topic and partition
|
ConsumerRecord(String topic,
int partition,
long offset,
long timestamp,
org.apache.kafka.common.record.TimestampType timestampType,
long checksum,
int serializedKeySize,
int serializedValueSize,
K key,
V value)
Deprecated.
use one of the constructors without a `checksum` parameter. This constructor will be removed in
Apache Kafka 4.0 (deprecated since 3.0).
|
ConsumerRecord(String topic,
int partition,
long offset,
long timestamp,
org.apache.kafka.common.record.TimestampType timestampType,
Long checksum,
int serializedKeySize,
int serializedValueSize,
K key,
V value,
Headers headers)
Deprecated.
use one of the constructors without a `checksum` parameter. This constructor will be removed in
Apache Kafka 4.0 (deprecated since 3.0).
|
ConsumerRecord(String topic,
int partition,
long offset,
long timestamp,
org.apache.kafka.common.record.TimestampType timestampType,
Long checksum,
int serializedKeySize,
int serializedValueSize,
K key,
V value,
Headers headers,
Optional<Integer> leaderEpoch)
Deprecated.
use one of the constructors without a `checksum` parameter. This constructor will be removed in
Apache Kafka 4.0 (deprecated since 3.0).
|
Modifier and Type | Method and Description |
---|---|
Headers |
headers()
The headers (never null)
|
K |
key()
The key (or null if no key is specified)
|
Optional<Integer> |
leaderEpoch()
Get the leader epoch for the record if available
|
long |
offset()
The position of this record in the corresponding Kafka partition.
|
int |
partition()
The partition from which this record is received
|
int |
serializedKeySize()
The size of the serialized, uncompressed key in bytes.
|
int |
serializedValueSize()
The size of the serialized, uncompressed value in bytes.
|
long |
timestamp()
The timestamp of this record
|
org.apache.kafka.common.record.TimestampType |
timestampType()
The timestamp type of this record
|
String |
topic()
The topic this record is received from (never null)
|
String |
toString() |
V |
value()
The value
|
public static final long NO_TIMESTAMP
public static final int NULL_SIZE
@Deprecated public static final int NULL_CHECKSUM
public ConsumerRecord(String topic, int partition, long offset, K key, V value)
topic
- The topic this record is received frompartition
- The partition of the topic this record is received fromoffset
- The offset of this record in the corresponding Kafka partitionkey
- The key of the record, if one exists (null is allowed)value
- The record contentspublic ConsumerRecord(String topic, int partition, long offset, long timestamp, org.apache.kafka.common.record.TimestampType timestampType, int serializedKeySize, int serializedValueSize, K key, V value, Headers headers, Optional<Integer> leaderEpoch)
topic
- The topic this record is received frompartition
- The partition of the topic this record is received fromoffset
- The offset of this record in the corresponding Kafka partitiontimestamp
- The timestamp of the record.timestampType
- The timestamp typeserializedKeySize
- The length of the serialized keyserializedValueSize
- The length of the serialized valuekey
- The key of the record, if one exists (null is allowed)value
- The record contentsheaders
- The headers of the recordleaderEpoch
- Optional leader epoch of the record (may be empty for legacy record formats)@Deprecated public ConsumerRecord(String topic, int partition, long offset, long timestamp, org.apache.kafka.common.record.TimestampType timestampType, long checksum, int serializedKeySize, int serializedValueSize, K key, V value)
topic
- The topic this record is received frompartition
- The partition of the topic this record is received fromoffset
- The offset of this record in the corresponding Kafka partitiontimestamp
- The timestamp of the record.timestampType
- The timestamp typeserializedKeySize
- The length of the serialized keyserializedValueSize
- The length of the serialized valuekey
- The key of the record, if one exists (null is allowed)value
- The record contents@Deprecated public ConsumerRecord(String topic, int partition, long offset, long timestamp, org.apache.kafka.common.record.TimestampType timestampType, Long checksum, int serializedKeySize, int serializedValueSize, K key, V value, Headers headers)
topic
- The topic this record is received frompartition
- The partition of the topic this record is received fromoffset
- The offset of this record in the corresponding Kafka partitiontimestamp
- The timestamp of the record.timestampType
- The timestamp typeserializedKeySize
- The length of the serialized keyserializedValueSize
- The length of the serialized valuekey
- The key of the record, if one exists (null is allowed)value
- The record contentsheaders
- The headers of the record.@Deprecated public ConsumerRecord(String topic, int partition, long offset, long timestamp, org.apache.kafka.common.record.TimestampType timestampType, Long checksum, int serializedKeySize, int serializedValueSize, K key, V value, Headers headers, Optional<Integer> leaderEpoch)
topic
- The topic this record is received frompartition
- The partition of the topic this record is received fromoffset
- The offset of this record in the corresponding Kafka partitiontimestamp
- The timestamp of the record.timestampType
- The timestamp typeserializedKeySize
- The length of the serialized keyserializedValueSize
- The length of the serialized valuekey
- The key of the record, if one exists (null is allowed)value
- The record contentsheaders
- The headers of the recordleaderEpoch
- Optional leader epoch of the record (may be empty for legacy record formats)public String topic()
public int partition()
public Headers headers()
public K key()
public V value()
public long offset()
public long timestamp()
public org.apache.kafka.common.record.TimestampType timestampType()
public int serializedKeySize()
public int serializedValueSize()
public Optional<Integer> leaderEpoch()