org.apache.kafka.clients.consumer
Class ConsumerRecord

java.lang.Object
  extended by org.apache.kafka.clients.consumer.ConsumerRecord

public final class ConsumerRecord
extends java.lang.Object

A key/value pair to be received from Kafka. This consists of a topic name and a partition number, from which the record is being received and an offset that points to the record in a Kafka partition.


Constructor Summary
ConsumerRecord(java.lang.String topic, int partitionId, byte[] key, byte[] value, long offset)
          Creates a record to be received from a specified topic and partition
ConsumerRecord(java.lang.String topic, int partitionId, byte[] value, long offset)
          Create a record with no key
ConsumerRecord(java.lang.String topic, int partitionId, java.lang.Exception error)
          Creates a record with an error code
 
Method Summary
 java.lang.Exception error()
           
 byte[] key()
          The key (or null if no key is specified)
 long offset()
          The position of this record in the corresponding Kafka partition.
 int partition()
          The partition from which this record is received
 java.lang.String topic()
          The topic this record is received from
 TopicPartition topicAndPartition()
          The TopicPartition object containing the topic and partition
 byte[] value()
          The value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsumerRecord

public ConsumerRecord(java.lang.String topic,
                      int partitionId,
                      byte[] key,
                      byte[] value,
                      long offset)
Creates a record to be received from a specified topic and partition

Parameters:
topic - The topic this record is received from
partitionId - The partition of the topic this record is received from
key - The key of the record, if one exists
value - The record contents
offset - The offset of this record in the corresponding Kafka partition

ConsumerRecord

public ConsumerRecord(java.lang.String topic,
                      int partitionId,
                      byte[] value,
                      long offset)
Create a record with no key

Parameters:
topic - The topic this record is received from
partitionId - The partition of the topic this record is received from
value - The record contents
offset - The offset of this record in the corresponding Kafka partition

ConsumerRecord

public ConsumerRecord(java.lang.String topic,
                      int partitionId,
                      java.lang.Exception error)
Creates a record with an error code

Parameters:
topic - The topic this record is received from
partitionId - The partition of the topic this record is received from
error - The exception corresponding to the error code returned by the server for this topic partition
Method Detail

topic

public java.lang.String topic()
The topic this record is received from


partition

public int partition()
The partition from which this record is received


topicAndPartition

public TopicPartition topicAndPartition()
The TopicPartition object containing the topic and partition


key

public byte[] key()
           throws java.lang.Exception
The key (or null if no key is specified)

Throws:
java.lang.Exception - The exception thrown while fetching this record.

value

public byte[] value()
             throws java.lang.Exception
The value

Throws:
java.lang.Exception - The exception thrown while fetching this record.

offset

public long offset()
            throws java.lang.Exception
The position of this record in the corresponding Kafka partition.

Throws:
java.lang.Exception - The exception thrown while fetching this record.

error

public java.lang.Exception error()