Skip to main content

ConsumerConfig

Struct ConsumerConfig 

Source
pub struct ConsumerConfig { /* private fields */ }
Expand description

The consumer configuration keys

Implementations§

Source§

impl ConsumerConfig

Source

pub const GROUP_ID_CONFIG: &'static str = "group.id"

Config key: group.id.

Source

pub const GROUP_INSTANCE_ID_CONFIG: &'static str = "group.instance.id"

Config key: group.instance.id.

Source

pub const GROUP_PROTOCOL_CONFIG: &'static str = "group.protocol"

Config key: group.protocol.

Source

pub const DEFAULT_GROUP_PROTOCOL: &'static str = "classic"

Default value of group.protocol. Matches Java’s DEFAULT_GROUP_PROTOCOL.

Source

pub const GROUP_REMOTE_ASSIGNOR_CONFIG: &'static str = "group.remote.assignor"

Config key: group.remote.assignor.

Source

pub const MAX_POLL_RECORDS_CONFIG: &'static str = "max.poll.records"

Config key: max.poll.records.

Source

pub const DEFAULT_MAX_POLL_RECORDS: i32 = 500

Default value of max.poll.records.

Source

pub const MAX_POLL_INTERVAL_MS_CONFIG: &'static str = "max.poll.interval.ms"

Config key: max.poll.interval.ms.

Source

pub const SESSION_TIMEOUT_MS_CONFIG: &'static str = "session.timeout.ms"

Config key: session.timeout.ms.

Source

pub const HEARTBEAT_INTERVAL_MS_CONFIG: &'static str = "heartbeat.interval.ms"

Config key: heartbeat.interval.ms.

Source

pub const BOOTSTRAP_SERVERS_CONFIG: &'static str = "bootstrap.servers"

Config key: bootstrap.servers.

Source

pub const CLIENT_DNS_LOOKUP_CONFIG: &'static str = CommonClientConfigs::CLIENT_DNS_LOOKUP_CONFIG

Config key: client.dns.lookup. Java’s ConsumerConfig declares it as its own public alias of CommonClientConfigs.CLIENT_DNS_LOOKUP_CONFIG.

Source

pub const CLIENT_ID_CONFIG: &'static str = "client.id"

Config key: client.id.

Source

pub const CLIENT_RACK_CONFIG: &'static str = crate::CommonClientConfigs::CLIENT_RACK_CONFIG

Config key: client.rack.

Source

pub const DEFAULT_CLIENT_RACK: &'static str = crate::CommonClientConfigs::DEFAULT_CLIENT_RACK

Default value of client.rack: no rack.

Source

pub const ENABLE_AUTO_COMMIT_CONFIG: &'static str = "enable.auto.commit"

Config key: enable.auto.commit.

Source

pub const AUTO_COMMIT_INTERVAL_MS_CONFIG: &'static str = "auto.commit.interval.ms"

Config key: auto.commit.interval.ms.

Source

pub const PARTITION_ASSIGNMENT_STRATEGY_CONFIG: &'static str = "partition.assignment.strategy"

Config key: partition.assignment.strategy.

Source

pub const AUTO_OFFSET_RESET_CONFIG: &'static str = "auto.offset.reset"

Config key: auto.offset.reset.

What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted):

  • earliest: automatically reset the offset to the earliest offset
  • latest: automatically reset the offset to the latest offset
  • by_duration:<duration>: automatically reset the offset to a configured <duration> from the current timestamp. <duration> must be specified in ISO8601 format (PnDTnHnMn.nS). Negative duration is not allowed.
  • none: return an error to the consumer if no previous offset is found for the consumer’s group
  • anything else: return an error to the consumer.

Note that increasing a topic’s partition count while this config is set to latest may cause silent message loss: producers may begin appending records to a newly created partition before the consumer discovers it, and latest resets the position to the log end offset, skipping any records produced during that discovery gap.

To avoid this, prefer by_duration:<duration>. When a partition has no committed offset, by_duration determines the starting position by issuing a ListOffsets lookup for now() - duration. If the target timestamp is earlier than the partition’s creation time, the lookup returns the partition’s start offset, ensuring that records produced during the discovery window are still consumed. Size the duration to cover the worst-case partition-discovery latency for the group protocol in use:

  • With the consumer group protocol (KIP-848), newly assigned partitions are pushed on the next group heartbeat, so a value at least as large as group.consumer.heartbeat.interval.ms (server default 5000 ms) is sufficient, for example by_duration:PT5S.
  • With the classic group protocol, new partitions are discovered through periodic metadata refresh and a subsequent rebalance, so the duration must exceed metadata.max.age.ms (client default 300000 ms) plus the rebalance time, for example by_duration:PT6M.

Consumers with a valid committed offset are unaffected. The reset applies only to partitions whose offset is missing or out of range, so by_duration does not force existing consumers to replay historical data on restart.

(Text of Java’s ConsumerConfig.AUTO_OFFSET_RESET_DOC, as rewritten by KAFKA-20539. This client implements only the consumer group protocol; the classic item is kept because the setting itself is protocol-independent.)

Source

pub const FETCH_MIN_BYTES_CONFIG: &'static str = "fetch.min.bytes"

Config key: fetch.min.bytes.

Source

pub const DEFAULT_FETCH_MIN_BYTES: i32 = 1

Default value of fetch.min.bytes.

Source

pub const FETCH_MAX_BYTES_CONFIG: &'static str = "fetch.max.bytes"

Config key: fetch.max.bytes.

Source

pub const DEFAULT_FETCH_MAX_BYTES: i32

Default value of fetch.max.bytes.

Source

pub const FETCH_MAX_WAIT_MS_CONFIG: &'static str = "fetch.max.wait.ms"

Config key: fetch.max.wait.ms.

Source

pub const DEFAULT_FETCH_MAX_WAIT_MS: i32 = 500

Default value of fetch.max.wait.ms.

Source

pub const MAX_PARTITION_FETCH_BYTES_CONFIG: &'static str = "max.partition.fetch.bytes"

Config key: max.partition.fetch.bytes.

Source

pub const DEFAULT_MAX_PARTITION_FETCH_BYTES: i32

Default value of max.partition.fetch.bytes.

Source

pub const CHECK_CRCS_CONFIG: &'static str = "check.crcs"

Config key: check.crcs.

Source

pub const SEND_BUFFER_CONFIG: &'static str = "send.buffer.bytes"

Config key: send.buffer.bytes.

Source

pub const RECEIVE_BUFFER_CONFIG: &'static str = "receive.buffer.bytes"

Config key: receive.buffer.bytes.

Source

pub const SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG: &'static str = "socket.connection.setup.timeout.ms"

Config key: socket.connection.setup.timeout.ms.

Source

pub const SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG: &'static str = "socket.connection.setup.timeout.max.ms"

Config key: socket.connection.setup.timeout.max.ms.

Source

pub const CONNECTIONS_MAX_IDLE_MS_CONFIG: &'static str = "connections.max.idle.ms"

Config key: connections.max.idle.ms.

Source

pub const RECONNECT_BACKOFF_MS_CONFIG: &'static str = "reconnect.backoff.ms"

Config key: reconnect.backoff.ms.

Source

pub const RECONNECT_BACKOFF_MAX_MS_CONFIG: &'static str = "reconnect.backoff.max.ms"

Config key: reconnect.backoff.max.ms.

Source

pub const RETRY_BACKOFF_MS_CONFIG: &'static str = "retry.backoff.ms"

Config key: retry.backoff.ms.

Source

pub const RETRY_BACKOFF_MAX_MS_CONFIG: &'static str = "retry.backoff.max.ms"

Config key: retry.backoff.max.ms.

Source

pub const BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG: &'static str = CommonClientConfigs::BOOTSTRAP_RESOLVE_TIMEOUT_MS_CONFIG

Config key: bootstrap.resolve.timeout.ms (KIP-909): selects the client’s bootstrap DNS resolution mode. 0 (the default) resolves bootstrap.servers synchronously when the consumer is created, and a resolution failure fails creation with a config error. A positive value resolves asynchronously, retrying for at most this long before every subsequent call fails with an unrecoverable BootstrapResolutionError; the consumer must then be closed and re-created. Setting a positive value enables an evolving feature whose compatibility may be broken in a minor release.

Source

pub const REQUEST_TIMEOUT_MS_CONFIG: &'static str = "request.timeout.ms"

Config key: request.timeout.ms.

Source

pub const DEFAULT_API_TIMEOUT_MS_CONFIG: &'static str = "default.api.timeout.ms"

Config key: default.api.timeout.ms.

Source

pub const METADATA_MAX_AGE_CONFIG: &'static str = "metadata.max.age.ms"

Config key: metadata.max.age.ms.

Source

pub const EXCLUDE_INTERNAL_TOPICS_CONFIG: &'static str = "exclude.internal.topics"

Config key: exclude.internal.topics.

Source

pub const DEFAULT_EXCLUDE_INTERNAL_TOPICS: bool = true

Default value of exclude.internal.topics.

Source

pub const ISOLATION_LEVEL_CONFIG: &'static str = "isolation.level"

Config key: isolation.level.

Source

pub const DEFAULT_ISOLATION_LEVEL: &'static str = "read_committed"

Default for isolation.level: read_committed, so a consumer returns only the transactional records that were committed.

WARNING: Java’s default is read_uncommitted. read_committed is librdkafka’s default, which users of the other Confluent clients expect. Set isolation.level=read_uncommitted for Java’s behaviour.

Source

pub const ALLOW_AUTO_CREATE_TOPICS_CONFIG: &'static str = "allow.auto.create.topics"

Config key: allow.auto.create.topics.

Source

pub const DEFAULT_ALLOW_AUTO_CREATE_TOPICS: bool = true

Default value of allow.auto.create.topics.

Source

pub const METRICS_SAMPLE_WINDOW_MS_CONFIG: &'static str = "metrics.sample.window.ms"

Config key: metrics.sample.window.ms.

Source

pub const METRICS_NUM_SAMPLES_CONFIG: &'static str = "metrics.num.samples"

Config key: metrics.num.samples.

Source

pub const METRICS_RECORDING_LEVEL_CONFIG: &'static str = "metrics.recording.level"

Config key: metrics.recording.level.

Source

pub const SHARE_ACKNOWLEDGEMENT_MODE_CONFIG: &'static str = "share.acknowledgement.mode"

Config key: share.acknowledgement.mode.

Source

pub const SHARE_ACQUIRE_MODE_CONFIG: &'static str = "share.acquire.mode"

Config key: share.acquire.mode.

Source

pub fn new(props: &HashMap<String, String>) -> Result<Self, Error>

Constructs a new ConsumerConfig with the given properties.

§Arguments
  • props - The consumer configuration properties
§Errors
  • Error::is_config_error if a value is invalid, the settings conflict, or sasl.mechanism is not PLAIN under a SASL security.protocol.
  • Error::is_invalid_configuration_error if enable.auto.commit is true without a group.id.
§Translation notes

WARNING: sasl.mechanism must be PLAIN.

Source

pub fn get_short(&self, key: &str) -> Result<Option<i16>, Error>

The SHORT configuration key. Reading a key marks it used (Self::unused).

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_int(&self, key: &str) -> Result<Option<i32>, Error>

The INT configuration key. Reading a key marks it used (Self::unused).

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_long(&self, key: &str) -> Result<Option<i64>, Error>

The LONG configuration key. Reading a key marks it used (Self::unused).

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_double(&self, key: &str) -> Result<Option<f64>, Error>

The DOUBLE configuration key. Reading a key marks it used (Self::unused).

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_list(&self, key: &str) -> Result<Option<&[String]>, Error>

The LIST configuration key, borrowed from the parsed values. Reading a key marks it used (Self::unused).

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_boolean(&self, key: &str) -> Result<Option<bool>, Error>

The BOOLEAN configuration key. Reading a key marks it used (Self::unused).

enable.auto.commit answers the value postProcessParsedConfig settled on: false without a group.id when it was not set.

§Arguments
  • key - the configuration name
§Returns

The value, None for Java’s null.

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn get_string(&self, key: &str) -> Result<Option<&str>, Error>

The STRING configuration key, trimmed. Reading a key marks it used (Self::unused).

client.id answers the resolved id: when the property is unset, new derives it the way Java’s maybeOverrideClientId does, so this is the id the consumer reports to the brokers. security.protocol answers the value as written, trimmed ("sasl_ssl"), as Java’s does: its validator accepts it case-insensitively without changing it. A PASSWORD configuration that is not set answers None, as Java’s null default casts to String.

§Arguments
  • key - the configuration name
§Returns

The value, None when it has no value (Java’s null, e.g. an unset group.id).

§Errors
  • Error::is_config_error with Java’s Unknown configuration '<key>' if key is not a configuration this class defines.
  • Error::is_local_illegal_argument_error if key is a configuration of another type, where Java’s cast fails with a ClassCastException.
Source

pub fn unused(&self) -> HashSet<String>

Returns the keys of the properties this configuration was built from that were never read: through a getter, or by the consumer built from it.

Source

pub fn ignore(&self, key: &str)

Marks the configuration key used without reading it.

§Arguments
  • key - the configuration name
Source

pub fn log_unused(&self)

Info level log for any unused configurations

Source

pub fn config_names() -> HashSet<String>

The names of the configurations this class defines.

§Returns

The set of configuration keys

Trait Implementations§

Source§

impl Debug for ConsumerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ConsumerConfig

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ConsumerConfig

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ConsumerConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V