pub struct ProducerConfig { /* private fields */ }Expand description
Configuration for the Kafka Producer.
Documentation for these configurations can be found in the Kafka documentation.
Corresponds to org.apache.kafka.clients.producer.ProducerConfig.
Implementations§
Source§impl ProducerConfig
impl ProducerConfig
Sourcepub const MAX_IN_FLIGHT_REQUESTS_FOR_IDEMPOTENCE: i32 = MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION_FOR_IDEMPOTENCE
pub const MAX_IN_FLIGHT_REQUESTS_FOR_IDEMPOTENCE: i32 = MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION_FOR_IDEMPOTENCE
Maximum number of in-flight requests per connection when idempotence is enabled.
Sourcepub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"
pub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"
Config key: bootstrap.servers
Sourcepub const CLIENT_DNS_LOOKUP_CONFIG: &'static str = CommonClientConfigs::CLIENT_DNS_LOOKUP_CONFIG
pub const CLIENT_DNS_LOOKUP_CONFIG: &'static str = CommonClientConfigs::CLIENT_DNS_LOOKUP_CONFIG
Config key: client.dns.lookup. Java’s ProducerConfig.java declares it as its
own public alias of CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG.
Sourcepub const CLIENT_ID_CONFIG: &'static str = "client.id"
pub const CLIENT_ID_CONFIG: &'static str = "client.id"
Config key: client.id
Sourcepub const BATCH_SIZE_CONFIG: &'static str = "batch.size"
pub const BATCH_SIZE_CONFIG: &'static str = "batch.size"
Config key: batch.size
Sourcepub const LINGER_MS_CONFIG: &'static str = "linger.ms"
pub const LINGER_MS_CONFIG: &'static str = "linger.ms"
Config key: linger.ms
Sourcepub const BUFFER_MEMORY_CONFIG: &'static str = "buffer.memory"
pub const BUFFER_MEMORY_CONFIG: &'static str = "buffer.memory"
Config key: buffer.memory
Sourcepub const MAX_BLOCK_MS_CONFIG: &'static str = "max.block.ms"
pub const MAX_BLOCK_MS_CONFIG: &'static str = "max.block.ms"
Config key: max.block.ms
Sourcepub const ACKS_CONFIG: &'static str = "acks"
pub const ACKS_CONFIG: &'static str = "acks"
Config key: acks
Sourcepub const RETRIES_CONFIG: &'static str = "retries"
pub const RETRIES_CONFIG: &'static str = "retries"
Config key: retries
Sourcepub const DELIVERY_TIMEOUT_MS_CONFIG: &'static str = "delivery.timeout.ms"
pub const DELIVERY_TIMEOUT_MS_CONFIG: &'static str = "delivery.timeout.ms"
Config key: delivery.timeout.ms
Sourcepub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"
pub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"
Config key: request.timeout.ms
Sourcepub const ENABLE_IDEMPOTENCE_CONFIG: &'static str = "enable.idempotence"
pub const ENABLE_IDEMPOTENCE_CONFIG: &'static str = "enable.idempotence"
Config key: enable.idempotence
Sourcepub const MAX_REQUEST_SIZE_CONFIG: &'static str = "max.request.size"
pub const MAX_REQUEST_SIZE_CONFIG: &'static str = "max.request.size"
Config key: max.request.size
Sourcepub const MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION: &'static str = "max.in.flight.requests.per.connection"
pub const MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION: &'static str = "max.in.flight.requests.per.connection"
Config key: max.in.flight.requests.per.connection
Sourcepub const COMPRESSION_TYPE_CONFIG: &'static str = "compression.type"
pub const COMPRESSION_TYPE_CONFIG: &'static str = "compression.type"
Config key: compression.type
Sourcepub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"
pub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"
Config key: connections.max.idle.ms
Sourcepub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"
pub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"
Config key: reconnect.backoff.ms
Sourcepub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"
pub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"
Config key: reconnect.backoff.max.ms
Sourcepub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"
pub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"
Config key: retry.backoff.ms
Sourcepub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"
pub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"
Config key: retry.backoff.max.ms
Sourcepub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"
pub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"
Config key: send.buffer.bytes
Sourcepub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"
pub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"
Config key: receive.buffer.bytes
Sourcepub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"
pub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"
Config key: metadata.max.age.ms
Sourcepub const METADATA_MAX_IDLE_CONFIG: &'static str = "metadata.max.idle.ms"
pub const METADATA_MAX_IDLE_CONFIG: &'static str = "metadata.max.idle.ms"
Config key: metadata.max.idle.ms
Sourcepub const PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG: &'static str = "partitioner.adaptive.partitioning.enable"
pub const PARTITIONER_ADAPTIVE_PARTITIONING_ENABLE_CONFIG: &'static str = "partitioner.adaptive.partitioning.enable"
Config key: partitioner.adaptive.partitioning.enable
Sourcepub const PARTITIONER_AVAILABILITY_TIMEOUT_MS_CONFIG: &'static str = "partitioner.availability.timeout.ms"
pub const PARTITIONER_AVAILABILITY_TIMEOUT_MS_CONFIG: &'static str = "partitioner.availability.timeout.ms"
Config key: partitioner.availability.timeout.ms
Sourcepub const PARTITIONER_IGNORE_KEYS_CONFIG: &'static str = "partitioner.ignore.keys"
pub const PARTITIONER_IGNORE_KEYS_CONFIG: &'static str = "partitioner.ignore.keys"
Config key: partitioner.ignore.keys
Sourcepub const PARTITIONER_TYPE_CONFIG: &'static str = "partitioner.type"
pub const PARTITIONER_TYPE_CONFIG: &'static str = "partitioner.type"
Config key: partitioner.type
Sourcepub const CONSISTENT_RANDOM_PARTITIONER: &'static str = "ConsistentRandomPartitioner"
pub const CONSISTENT_RANDOM_PARTITIONER: &'static str = "ConsistentRandomPartitioner"
Accepted partitioner.type value selecting the CRC-32 key hash
(the crate-internal KeyHasher::Crc32) — the default, librdkafka consistent_random parity.
Sourcepub const MURMUR2_RANDOM_PARTITIONER: &'static str = "Murmur2RandomPartitioner"
pub const MURMUR2_RANDOM_PARTITIONER: &'static str = "Murmur2RandomPartitioner"
Accepted partitioner.type value selecting the murmur2 key hash
(the crate-internal KeyHasher::Murmur2) — exact Java-client parity.
Sourcepub const ROUND_ROBIN_PARTITIONER: &'static str = "RoundRobinPartitioner"
pub const ROUND_ROBIN_PARTITIONER: &'static str = "RoundRobinPartitioner"
Accepted partitioner.type value selecting the
RoundRobinPartitioner.
Sourcepub const TRANSACTIONAL_ID_CONFIG: &'static str = "transactional.id"
pub const TRANSACTIONAL_ID_CONFIG: &'static str = "transactional.id"
Config key: transactional.id
Sourcepub const TRANSACTION_TIMEOUT_CONFIG: &'static str = "transaction.timeout.ms"
pub const TRANSACTION_TIMEOUT_CONFIG: &'static str = "transaction.timeout.ms"
Config key: transaction.timeout.ms
Sourcepub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"
pub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"
Config key: metrics.sample.window.ms
Sourcepub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"
pub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"
Config key: metrics.num.samples
Sourcepub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"
pub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"
Config key: metrics.recording.level
Sourcepub const TRANSACTION_TWO_PHASE_COMMIT_ENABLE_CONFIG: &'static str = "transaction.two.phase.commit.enable"
pub const TRANSACTION_TWO_PHASE_COMMIT_ENABLE_CONFIG: &'static str = "transaction.two.phase.commit.enable"
Config key: transaction.two.phase.commit.enable
Sourcepub const SECURITY_PROTOCOL_CONFIG: &'static str = CommonClientConfigs::SECURITY_PROTOCOL_CONFIG
pub const SECURITY_PROTOCOL_CONFIG: &'static str = CommonClientConfigs::SECURITY_PROTOCOL_CONFIG
Config key: security.protocol
Sourcepub const SASL_MECHANISM_CONFIG: &'static str = SaslConfigs::SASL_MECHANISM
pub const SASL_MECHANISM_CONFIG: &'static str = SaslConfigs::SASL_MECHANISM
Config key: sasl.mechanism
Sourcepub const SASL_JAAS_CONFIG: &'static str = SaslConfigs::SASL_JAAS_CONFIG
pub const SASL_JAAS_CONFIG: &'static str = SaslConfigs::SASL_JAAS_CONFIG
Config key: sasl.jaas.config
Sourcepub fn new(props: &HashMap<String, String>) -> Result<Self, Error>
pub fn new(props: &HashMap<String, String>) -> Result<Self, Error>
Creates a ProducerConfig from a map of string key-value pairs.
This is the Rust equivalent of Java’s new ProducerConfig(Map<String, Object>)
or new ProducerConfig(Properties). Starts with default values and overrides
each field that has a matching entry in the map.
Unknown keys are logged as warnings and ignored, matching Java’s behavior.
§Errors
Returns Error::LocalIllegalArgument if a value cannot be parsed for its
expected type (e.g., "abc" for an integer field).
Sourcepub fn set_partitioner<K: 'static, V: 'static>(
self,
partitioner: Box<dyn Partitioner<K, V>>,
) -> Self
pub fn set_partitioner<K: 'static, V: 'static>( self, partitioner: Box<dyn Partitioner<K, V>>, ) -> Self
Sets the Partitioner that determines which partition each record
goes to: the value of Java’s partitioner.class.
Java names a class, which the producer instantiates by reflection; here
the partitioner itself is the value. KafkaProducer::new
configures it with the user configs plus the resolved client.id, as
Java does (KafkaProducer.java:381-388), and closes it on close. As
with any configured partitioner, adaptive partitioning is then disabled.
The producer built from this config takes ownership of the partitioner.
This replaces a partitioner.type given in the properties passed to
new, as a later value for the same key would.
The partitioner’s K / V must be the record types of the producer built
from this config; otherwise KafkaProducer::new fails with
“<partitioner> is not an instance of <expected>”.