librdkafka
The Apache Kafka C/C++ client library
rd_kafka_message_t Struct Reference

A Kafka message as returned by the rd_kafka_consume*() family of functions as well as provided to the Producer dr_msg_cb(). More...

#include <rdkafka.h>

Data Fields

rd_kafka_resp_err_t err
 
rd_kafka_topic_t * rkt
 
int32_t partition
 
void * payload
 
size_t len
 
void * key
 
size_t key_len
 
int64_t offset
 
void * _private
 

Detailed Description

A Kafka message as returned by the rd_kafka_consume*() family of functions as well as provided to the Producer dr_msg_cb().

For the consumer this object has two purposes:

  • provide the application with a consumed message. (err == 0)
  • report per-topic+partition consumer errors (err != 0)

The application must check err to decide what action to take.

When the application is finished with a message it must call rd_kafka_message_destroy() unless otherwise noted.

Field Documentation

§ err

rd_kafka_resp_err_t rd_kafka_message_t::err

Non-zero for error signaling.

§ rkt

rd_kafka_topic_t* rd_kafka_message_t::rkt

Topic

§ partition

int32_t rd_kafka_message_t::partition

Partition

§ payload

void* rd_kafka_message_t::payload

Producer: original message payload. Consumer: Depends on the value of err :

  • err==0: Message payload.
  • err!=0: Error string

§ len

size_t rd_kafka_message_t::len

Depends on the value of err :

  • err==0: Message payload length
  • err!=0: Error string length

§ key

void* rd_kafka_message_t::key

Depends on the value of err :

  • err==0: Optional message key

§ key_len

size_t rd_kafka_message_t::key_len

Depends on the value of err :

  • err==0: Optional message key length

§ offset

int64_t rd_kafka_message_t::offset

Consume:

  • Message offset (or offset for error if err!=0 if applicable).
  • dr_msg_cb: Message offset assigned by broker. If produce.offset.report is set then each message will have this field set, otherwise only the last message in each produced internal batch will have this field set, otherwise 0.

§ _private

void* rd_kafka_message_t::_private

Consume:

  • rdkafka private pointer: DO NOT MODIFY
  • dr_msg_cb: msg_opaque from produce() call

The documentation for this struct was generated from the following file: