Skip to content

Configuration

Matias Fontanini edited this page Apr 29, 2017 · 1 revision

Configuration objects allow easily configuring your consumers/producers. They allow setting parameters on librdkafka's configuration handles while allowing to use types such as integral values, strings and bools as values.

Example:

// Build a configuration to be used on e.g. a consumer/producer
Configuration config = {
    { "metadata.broker.list", "kafka-server:9092" },
    { "enable.auto.commit", false },
    { "queue.buffering.max.ms", 50 }
};

// Build a topic configuration
TopicConfiguration topic_config = {
    { "auto.offset.reset", "smallest" }
};

// Now configure it to be the default topic config
config.set_default_topic_config(topic_config);

Callbacks

Configuration objects support configuring callbacks that will later be used when consuming/producing messages. These all take std::functions as their arguments so you can use any functor that has a valid signature:

Configuration config = ...;
// Set the offset commit callback (maps to rd_kafka_conf_set_offset_commit_cb).
config.set_offset_commit_callback([](Consumer& consumer, Error error,
                                     const TopicPartitionList& topic_partitions) {
    // ....
});
Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy