class OffsetCommitRequest

Header File: <libkafka_asio/offset_commit_request.h>

Namespace: libkafka_asio

Implementation of the Kafka OffsetCommitRequest as described on the Kafka wiki. Offset commit requests are used to commit an offset value for one or more topic partitions of a Kafka consumer group. These kinds of requests require Kafka version or above. Offset commit requests must be sent to the current offset coordinator broker, which can be discovered using a ConsumerMetadata request.

Member Functions


void CommitOffset(const String& topic_name,
                  Int32 partition,
                  Int64 offset,
                  Int64 timestamp,
                  const String& metadata)

Adds an entry to this request to commit offset data for the given topic-partition using the optionally specified timestamp. If the special value constants::kDefaultOffsetCommitTimestampNow (-1) is given for the timestamp parameter, then the broker sets the time stamp to the receive time before committing the offset data.


void Clear()

Clears this request by removing all added commit-offset entries.


void set_consumer_group(const String& consumer_group)

Set the consumer group to commit the offset data for.


const String& consumer_group() const

Returns the consumer group string used by this request.


const Topics& topics() const

Returns a reference to the list of topics of this offset commit request. This method is mainly used internally for getting the request data during the conversion to the Kafka wire format.



struct Topic {
    String      topic_name;
    Partitions  partitions;
  • topic_name: Name of the topic to fetch data for.
  • partitions: Set of partitions of this topic.


struct Partition {
    Int64   offset;
    Int64   timestamp;
    String  metadata;
    Int32   partition;
  • partition: Number, identifying this topic partition.
  • offset: Offset that should be committed.
  • timestamp: Timestamp used for the commit.
  • metadata: Additional metadata.


typedef std::vector<Topic> Topics

Vector of Topic objects.


typedef std::vector<Partition> Partitions

Vector of Partition objects.


typedef OffsetCommitResponse ResponseType

Type of the response object of an offset commit request.


typedef MutableOffsetCommitResponse MutableResponseType

Type of a mutable response object for a offset commit request. This type is used by the library at when reading-in the response from a Kafka server.