librdkafka
The Apache Kafka C/C++ client library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RdKafka::Message Class Referenceabstract

Message object. More...

#include <rdkafkacpp.h>

Public Member Functions

virtual std::string errstr () const =0
 Accessor functions*. More...
 
virtual ErrorCode err () const =0
 
virtual Topictopic () const =0
 
virtual std::string topic_name () const =0
 
virtual int32_t partition () const =0
 
virtual void * payload () const =0
 
virtual size_t len () const =0
 
virtual const std::string * key () const =0
 
virtual const void * key_pointer () const =0
 
virtual size_t key_len () const =0
 
virtual int64_t offset () const =0
 
virtual MessageTimestamp timestamp () const =0
 
virtual void * msg_opaque () const =0
 
virtual int64_t latency () const =0
 
virtual struct rd_kafka_message_s * c_ptr ()=0
 Returns the underlying librdkafka C rd_kafka_message_t handle. More...
 

Detailed Description

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.

Member Function Documentation

virtual std::string RdKafka::Message::errstr ( ) const
pure virtual

Accessor functions*.

Remarks
Not all fields are present in all types of callbacks.
Returns
The error string if object represent an error event, else an empty string.
virtual ErrorCode RdKafka::Message::err ( ) const
pure virtual
Returns
The error code if object represents an error event, else 0.
virtual Topic* RdKafka::Message::topic ( ) const
pure virtual
Returns
the RdKafka::Topic object for a message (if applicable), or NULL if a corresponding RdKafka::Topic object has not been explicitly created with RdKafka::Topic::create(). In this case use topic_name() instead.
virtual std::string RdKafka::Message::topic_name ( ) const
pure virtual
Returns
Topic name (if applicable, else empty string)
virtual int32_t RdKafka::Message::partition ( ) const
pure virtual
Returns
Partition (if applicable)
virtual void* RdKafka::Message::payload ( ) const
pure virtual
Returns
Message payload (if applicable)
virtual size_t RdKafka::Message::len ( ) const
pure virtual
Returns
Message payload length (if applicable)
virtual const std::string* RdKafka::Message::key ( ) const
pure virtual
Returns
Message key as string (if applicable)
virtual const void* RdKafka::Message::key_pointer ( ) const
pure virtual
Returns
Message key as void pointer (if applicable)
virtual size_t RdKafka::Message::key_len ( ) const
pure virtual
Returns
Message key's binary length (if applicable)
virtual int64_t RdKafka::Message::offset ( ) const
pure virtual
Returns
Message or error offset (if applicable)
virtual MessageTimestamp RdKafka::Message::timestamp ( ) const
pure virtual
Returns
Message timestamp (if applicable)
virtual void* RdKafka::Message::msg_opaque ( ) const
pure virtual
Returns
The msg_opaque as provided to RdKafka::Producer::produce()
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.
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.
Remarks
The lifetime of the returned pointer is the same as the Message object this method is called on.
Include <rdkafka/rdkafka.h> prior to including <rdkafka/rdkafkacpp.h>
Returns
rd_kafka_message_t*

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