Message object.  
 More...
#include <rdkafkacpp.h>
Message object. 
This object represents either a single consumed or produced message, or an event (err() is set).
An application must check RdKafka::Message::err() to see if the object is a proper message (error is RdKafka::ERR_NO_ERROR) or a an error event. 
 
◆ Status
Message persistence status can be used by the application to find out if a produced message was persisted in the topic log. 
| Enumerator | 
|---|
| MSG_STATUS_NOT_PERSISTED  | Message was never transmitted to the broker, or failed with an error indicating it was not written to the log. Application retry risks ordering, but not duplication.  
 | 
| MSG_STATUS_POSSIBLY_PERSISTED  | Message was transmitted to broker, but no acknowledgement was received. Application retry risks ordering and duplication.  
 | 
| MSG_STATUS_PERSISTED  | Message was written to the log and fully acknowledged. No reason for application to retry. Note: this value should only be trusted with acks=all.  
 | 
 
 
◆ errstr()
  
  
      
        
          | virtual std::string RdKafka::Message::errstr  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
Accessor functions*. 
- Returns
 - The error string if object represent an error event, else an empty string. 
 
 
 
◆ err()
  
  
      
        
          | virtual ErrorCode RdKafka::Message::err  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - The error code if object represents an error event, else 0. 
 
 
 
◆ topic()
  
  
      
        
          | virtual Topic * RdKafka::Message::topic  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
 
◆ topic_name()
  
  
      
        
          | virtual std::string RdKafka::Message::topic_name  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Topic name (if applicable, else empty string) 
 
 
 
◆ partition()
  
  
      
        
          | virtual int32_t RdKafka::Message::partition  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Partition (if applicable) 
 
 
 
◆ payload()
  
  
      
        
          | virtual void * RdKafka::Message::payload  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message payload (if applicable) 
 
 
 
◆ len()
  
  
      
        
          | virtual size_t RdKafka::Message::len  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message payload length (if applicable) 
 
 
 
◆ key()
  
  
      
        
          | virtual const std::string * RdKafka::Message::key  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message key as string (if applicable) 
 
 
 
◆ key_pointer()
  
  
      
        
          | virtual const void * RdKafka::Message::key_pointer  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message key as void pointer (if applicable) 
 
 
 
◆ key_len()
  
  
      
        
          | virtual size_t RdKafka::Message::key_len  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message key's binary length (if applicable) 
 
 
 
◆ offset()
  
  
      
        
          | virtual int64_t RdKafka::Message::offset  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - Message or error offset (if applicable) 
 
 
 
◆ timestamp()
- Returns
 - Message timestamp (if applicable) 
 
 
 
◆ msg_opaque()
  
  
      
        
          | virtual void * RdKafka::Message::msg_opaque  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
 
◆ latency()
  
  
      
        
          | virtual int64_t RdKafka::Message::latency  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - the latency in microseconds for a produced message measured from the produce() call, or -1 if latency is not available. 
 
 
 
◆ c_ptr()
  
  
      
        
          | virtual struct rd_kafka_message_s * RdKafka::Message::c_ptr  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
pure virtual   | 
  
 
Returns the underlying librdkafka C rd_kafka_message_t handle. 
- Warning
 - Calling the C API on this handle is not recommended and there is no official support for it, but for cases where the C++ API does not provide the underlying functionality this C handle can be used to interact directly with the core librdkafka API.
 
- Returns
 rd_kafka_message_t* 
 
 
◆ headers() [1/2]
- Returns
 - the Headers instance for this Message, or NULL if there are no headers.
 
 
 
◆ headers() [2/2]
- Returns
 - the Headers instance for this Message (if applicable). If NULL is returned the reason is given in 
err, which is either ERR__NOENT if there were no headers, or another error code if header parsing failed. 
 
 
◆ broker_id()
  
  
      
        
          | virtual int32_t RdKafka::Message::broker_id  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - the broker id of the broker the message was produced to or fetched from, or -1 if not known/applicable. 
 
 
 
◆ leader_epoch()
  
  
      
        
          | virtual int32_t RdKafka::Message::leader_epoch  | 
          ( | 
           | ) | 
           const | 
         
       
   | 
  
pure virtual   | 
  
 
- Returns
 - the message's partition leader epoch at the time the message was fetched and if known, else -1. 
 
 
 
◆ offset_store()
  
  
      
        
          | virtual Error * RdKafka::Message::offset_store  | 
          ( | 
           | ) | 
           | 
         
       
   | 
  
pure virtual   | 
  
 
Store offset +1 for the consumed message. 
The message offset + 1 will be committed to broker according to `auto.commit.interval.ms` or manual offset-less commit()
- Warning
 - This method may only be called for partitions that are currently assigned. Non-assigned partitions will fail with ERR__STATE.
 
- 
Avoid storing offsets after calling seek() (et.al) as this may later interfere with resuming a paused partition, instead store offsets prior to calling seek.
 
- Returns
 - NULL on success or an error object on failure. 
 
 
 
The documentation for this class was generated from the following file: