librdkafka
The Apache Kafka C/C++ client library
RdKafka::Handle Class Referenceabstract

Base handle, super class for specific clients. More...

#include <rdkafkacpp.h>

Inheritance diagram for RdKafka::Handle:

Public Member Functions

virtual const std::string name () const =0
 
virtual const std::string memberid () const =0
 Returns the client's broker-assigned group member id. More...
 
virtual int poll (int timeout_ms)=0
 Polls the provided kafka handle for events. More...
 
virtual int outq_len ()=0
 Returns the current out queue length. More...
 
virtual ErrorCode metadata (bool all_topics, const Topic *only_rkt, Metadata **metadatap, int timeout_ms)=0
 Request Metadata from broker. More...
 
virtual ErrorCode pause (std::vector< TopicPartition *> &partitions)=0
 Pause producing or consumption for the provided list of partitions. More...
 
virtual ErrorCode resume (std::vector< TopicPartition *> &partitions)=0
 Resume producing or consumption for the provided list of partitions. More...
 
virtual ErrorCode query_watermark_offsets (const std::string &topic, int32_t partition, int64_t *low, int64_t *high, int timeout_ms)=0
 Query broker for low (oldest/beginning) and high (newest/end) offsets for partition. More...
 
virtual ErrorCode get_watermark_offsets (const std::string &topic, int32_t partition, int64_t *low, int64_t *high)=0
 Get last known low (oldest/beginning) and high (newest/end) offsets for partition. More...
 
virtual ErrorCode offsetsForTimes (std::vector< TopicPartition *> &offsets, int timeout_ms)=0
 Look up the offsets for the given partitions by timestamp. More...
 
virtual Queueget_partition_queue (const TopicPartition *partition)=0
 Retrieve queue for a given partition. More...
 
virtual ErrorCode set_log_queue (Queue *queue)=0
 Forward librdkafka logs (and debug) to the specified queue for serving with one of the ..poll() calls. More...
 

Detailed Description

Base handle, super class for specific clients.

Member Function Documentation

§ name()

virtual const std::string RdKafka::Handle::name ( ) const
pure virtual
Returns
the name of the handle

§ memberid()

virtual const std::string RdKafka::Handle::memberid ( ) const
pure virtual

Returns the client's broker-assigned group member id.

Remarks
This currently requires the high-level KafkaConsumer
Returns
Last assigned member id, or empty string if not currently a group member.

§ poll()

virtual int RdKafka::Handle::poll ( int  timeout_ms)
pure virtual

Polls the provided kafka handle for events.

Events will trigger application provided callbacks to be called.

The timeout_ms argument specifies the maximum amount of time (in milliseconds) that the call will block waiting for events. For non-blocking calls, provide 0 as timeout_ms. To wait indefinately for events, provide -1.

Events:

  • delivery report callbacks (if an RdKafka::DeliveryCb is configured) [producer]
  • event callbacks (if an RdKafka::EventCb is configured) [producer & consumer]
Remarks
An application should make sure to call poll() at regular intervals to serve any queued callbacks waiting to be called.
Warning
This method MUST NOT be used with the RdKafka::KafkaConsumer, use its RdKafka::KafkaConsumer::consume() instead.
Returns
the number of events served.

§ outq_len()

virtual int RdKafka::Handle::outq_len ( )
pure virtual

Returns the current out queue length.

The out queue contains messages and requests waiting to be sent to, or acknowledged by, the broker.

§ metadata()

virtual ErrorCode RdKafka::Handle::metadata ( bool  all_topics,
const Topic only_rkt,
Metadata **  metadatap,
int  timeout_ms 
)
pure virtual

Request Metadata from broker.

Parameters: all_topics - if non-zero: request info about all topics in cluster, if zero: only request info about locally known topics. only_rkt - only request info about this topic metadatap - pointer to hold metadata result. The *metadatap pointer must be released with delete. timeout_ms - maximum response time before failing.

Returns
RdKafka::ERR_NO_ERROR on success (in which case *metadatap will be set), else RdKafka::ERR__TIMED_OUT on timeout or other error code on error.

§ pause()

virtual ErrorCode RdKafka::Handle::pause ( std::vector< TopicPartition *> &  partitions)
pure virtual

Pause producing or consumption for the provided list of partitions.

Success or error is returned per-partition in the partitions list.

Returns
ErrorCode::NO_ERROR
See also
resume()

§ resume()

virtual ErrorCode RdKafka::Handle::resume ( std::vector< TopicPartition *> &  partitions)
pure virtual

Resume producing or consumption for the provided list of partitions.

Success or error is returned per-partition in the partitions list.

Returns
ErrorCode::NO_ERROR
See also
pause()

§ query_watermark_offsets()

virtual ErrorCode RdKafka::Handle::query_watermark_offsets ( const std::string &  topic,
int32_t  partition,
int64_t *  low,
int64_t *  high,
int  timeout_ms 
)
pure virtual

Query broker for low (oldest/beginning) and high (newest/end) offsets for partition.

Offsets are returned in *low and *high respectively.

Returns
RdKafka::ERR_NO_ERROR on success or an error code on failure.

§ get_watermark_offsets()

virtual ErrorCode RdKafka::Handle::get_watermark_offsets ( const std::string &  topic,
int32_t  partition,
int64_t *  low,
int64_t *  high 
)
pure virtual

Get last known low (oldest/beginning) and high (newest/end) offsets for partition.

The low offset is updated periodically (if statistics.interval.ms is set) while the high offset is updated on each fetched message set from the broker.

If there is no cached offset (either low or high, or both) then OFFSET_INVALID will be returned for the respective offset.

Offsets are returned in *low and *high respectively.

Returns
RdKafka::ERR_NO_ERROR on success or an error code on failure.
Remarks
Shall only be used with an active consumer instance.

§ offsetsForTimes()

virtual ErrorCode RdKafka::Handle::offsetsForTimes ( std::vector< TopicPartition *> &  offsets,
int  timeout_ms 
)
pure virtual

Look up the offsets for the given partitions by timestamp.

The returned offset for each partition is the earliest offset whose timestamp is greater than or equal to the given timestamp in the corresponding partition.

The timestamps to query are represented as offset in offsets on input, and offset() will return the closest earlier offset for the timestamp on output.

The function will block for at most timeout_ms milliseconds.

Remarks
Duplicate Topic+Partitions are not supported.
Errors are also returned per TopicPartition, see err()
Returns
an error code for general errors, else RdKafka::ERR_NO_ERROR in which case per-partition errors might be set.

§ get_partition_queue()

virtual Queue* RdKafka::Handle::get_partition_queue ( const TopicPartition partition)
pure virtual

Retrieve queue for a given partition.

Returns
The fetch queue for the given partition if successful. Else, NULL is returned.
Remarks
This function only works on consumers.

§ set_log_queue()

virtual ErrorCode RdKafka::Handle::set_log_queue ( Queue queue)
pure virtual

Forward librdkafka logs (and debug) to the specified queue for serving with one of the ..poll() calls.

This allows an application to serve log callbacks (log_cb) in its thread of choice.

Parameters
queueQueue to forward logs to. If the value is NULL the logs are forwarded to the main queue.
Remarks
The configuration property log.queue MUST also be set to true.
librdkafka maintains its own reference to the provided queue.
Returns
ERR_NO_ERROR on success or an error code on error.

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