public final class ConsumerConfigBuilder extends AbstractConfigBuilder<ConsumerConfigBuilder>
props| Modifier and Type | Method and Description |
|---|---|
static ConsumerConfigBuilder |
create() |
ConsumerConfigBuilder |
withAllowAutoCreateTopics(boolean allowAutoCreateTopics)
Allow automatic topic creation on the broker when
subscribing to or assigning a topic.
|
ConsumerConfigBuilder |
withAutoCommitInterval(Duration autoCommitInterval)
The frequency in milliseconds that the consumer offsets are auto-committed to Kafka if
enable.auto.commit is set to true. |
ConsumerConfigBuilder |
withAutoOffsetReset(org.apache.kafka.clients.consumer.OffsetResetStrategy autoOffsetReset)
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.
|
ConsumerConfigBuilder |
withCheckCRCs(boolean checkCRCs)
Automatically check the CRC32 of the records consumed.
|
ConsumerConfigBuilder |
withDefaultApiTimeout(Duration defaultApiTimeout)
Specifies the timeout for consumer APIs that could block.
|
ConsumerConfigBuilder |
withEnableAutoCommit(boolean enableAutoCommit)
If true the consumer's offset will be periodically committed in the background.
|
ConsumerConfigBuilder |
withExcludeInternalTopics(boolean excludeInternalTopics)
Whether internal topics matching a subscribed pattern should
be excluded from the subscription.
|
ConsumerConfigBuilder |
withFetchMaxBytes(int fetchMaxBytes)
The maximum amount of data the server should return for a fetch request.
|
ConsumerConfigBuilder |
withFetchMaxWait(Duration fetchMaxWait)
The maximum amount of time the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by fetch.min.bytes.
|
ConsumerConfigBuilder |
withFetchMinBytes(int fetchMinBytes)
The minimum amount of data the server should return for a fetch request.
|
ConsumerConfigBuilder |
withGroupId(String groupId)
A unique string that identifies the consumer group this consumer belongs to.
|
ConsumerConfigBuilder |
withGroupInstanceId(String groupInstanceId)
A unique identifier of the consumer instance provided by end user.
|
ConsumerConfigBuilder |
withHeartbeatInterval(Duration heartbeatInterval)
The expected time between heartbeats to the consumer
coordinator when using Kafka's group management facilities.
|
ConsumerConfigBuilder |
withInterceptorClasses(Class<? extends org.apache.kafka.clients.consumer.ConsumerInterceptor>... interceptorClasses)
A list of classes to use as interceptors.
|
ConsumerConfigBuilder |
withIsolationLevel(org.apache.kafka.common.IsolationLevel isolationLevel)
Controls how to read messages written transactionally.
|
ConsumerConfigBuilder |
withKeyDeserializer(Class<? extends org.apache.kafka.common.serialization.Deserializer> keyDeserializer)
Deserializer class for key that implements the
org.apache.kafka.common.serialization.Deserializer interface. |
ConsumerConfigBuilder |
withMaxPartitionFetchBytes(int maxPartitionFetchBytes)
The maximum amount of data per-partition the server
will return.
|
ConsumerConfigBuilder |
withMaxPollInterval(Duration maxPollInterval)
The maximum delay between invocations of poll() when using
consumer group management.
|
ConsumerConfigBuilder |
withMaxPollRecords(int maxPollRecords)
The maximum number of records returned in a single call to poll().
|
ConsumerConfigBuilder |
withPartitionAssignmentStrategy(Class<? extends org.apache.kafka.clients.consumer.ConsumerPartitionAssignor>... partitionAssignmentStrategy)
A list of class names or class types, ordered by preference, of supported assignors responsible for the partition assignment strategy that the client will use to distribute partition ownership amongst consumer instances when group management is used.
|
ConsumerConfigBuilder |
withSessionTimeout(Duration sessionTimeout)
The timeout used to detect consumer failures when using
Kafka's group management facility.
|
ConsumerConfigBuilder |
withValueDeserializer(Class<? extends org.apache.kafka.common.serialization.Deserializer> valueDeserializer)
Deserializer class for value that implements the
org.apache.kafka.common.serialization.Deserializer interface. |
buildMap, buildProperties, withBootstrapServers, withBootstrapServers, withClientDNSLookup, withClientId, withClientRack, withConnectionsMaxIdle, withCustom, withCustomMap, withMetadataMaxAge, withMetricReporterClasses, withMetricsNumSamples, withMetricsRecordingLevel, withMetricsSampleWindow, withReceiveBufferBytes, withReconnectBackoff, withReconnectBackoffMax, withRequestTimeout, withRetryBackoff, withSaslMechanism, withSecurityProtocol, withSecurityProviders, withSendBufferBytes, withSocketConnectionSetupTimeout, withSocketConnectionSetupTimeoutMaxpublic static ConsumerConfigBuilder create()
public ConsumerConfigBuilder withGroupId(String groupId)
subscribe(topic) or the Kafka-based offset management strategy.public ConsumerConfigBuilder withGroupInstanceId(String groupInstanceId)
public ConsumerConfigBuilder withMaxPollRecords(int maxPollRecords)
public ConsumerConfigBuilder withMaxPollInterval(Duration maxPollInterval)
public ConsumerConfigBuilder withSessionTimeout(Duration sessionTimeout)
group.min.session.timeout.ms
and group.max.session.timeout.ms.public ConsumerConfigBuilder withHeartbeatInterval(Duration heartbeatInterval)
session.timeout.ms, but typically should be set no higher
than 1/3 of that value. It can be adjusted even lower to control the expected time for normal rebalances.public ConsumerConfigBuilder withEnableAutoCommit(boolean enableAutoCommit)
public ConsumerConfigBuilder withAutoCommitInterval(Duration autoCommitInterval)
enable.auto.commit is set to true.@SafeVarargs public final ConsumerConfigBuilder withPartitionAssignmentStrategy(Class<? extends org.apache.kafka.clients.consumer.ConsumerPartitionAssignor>... partitionAssignmentStrategy)
org.apache.kafka.clients.consumer.ConsumerPartitionAssignor interface allows you to plug in a custom assignment strategy.public ConsumerConfigBuilder withAutoOffsetReset(org.apache.kafka.clients.consumer.OffsetResetStrategy autoOffsetReset)
public ConsumerConfigBuilder withFetchMinBytes(int fetchMinBytes)
public ConsumerConfigBuilder withFetchMaxBytes(int fetchMaxBytes)
message.max.bytes (broker config) or
max.message.bytes (topic config). Note that the consumer performs multiple fetches in parallel.public ConsumerConfigBuilder withFetchMaxWait(Duration fetchMaxWait)
public ConsumerConfigBuilder withMaxPartitionFetchBytes(int maxPartitionFetchBytes)
message.max.bytes (broker config) or
max.message.bytes (topic config). See FETCH_MAX_BYTES_CONFIG for limiting the consumer request size.public ConsumerConfigBuilder withCheckCRCs(boolean checkCRCs)
public ConsumerConfigBuilder withKeyDeserializer(Class<? extends org.apache.kafka.common.serialization.Deserializer> keyDeserializer)
org.apache.kafka.common.serialization.Deserializer interface.public ConsumerConfigBuilder withValueDeserializer(Class<? extends org.apache.kafka.common.serialization.Deserializer> valueDeserializer)
org.apache.kafka.common.serialization.Deserializer interface.public ConsumerConfigBuilder withDefaultApiTimeout(Duration defaultApiTimeout)
timeout parameter.@SafeVarargs public final ConsumerConfigBuilder withInterceptorClasses(Class<? extends org.apache.kafka.clients.consumer.ConsumerInterceptor>... interceptorClasses)
org.apache.kafka.clients.consumer.ConsumerInterceptor interface allows you to intercept (and possibly mutate) records
received by the consumer. By default, there are no interceptors.public ConsumerConfigBuilder withExcludeInternalTopics(boolean excludeInternalTopics)
public ConsumerConfigBuilder withIsolationLevel(org.apache.kafka.common.IsolationLevel isolationLevel)
Controls how to read messages written transactionally. If set to read_committed, consumer.poll() will only return
transactional messages which have been committed. If set to read_uncommitted' (the default), consumer.poll() will return all messages, even transactional messages
which have been aborted. Non-transactional messages will be returned unconditionally in either mode.
Messages will always be returned in offset order. Hence, in
read_committed mode, consumer.poll() will only return messages up to the last stable offset (LSO), which is the one less than the offset of the first open transaction.
In particular any messages appearing after messages belonging to ongoing transactions will be withheld until the relevant transaction has been completed. As a result, read_committed
consumers will not be able to read up to the high watermark when there are in flight transactions.
Further, when in read_committed the seekToEnd method will
return the LSO
public ConsumerConfigBuilder withAllowAutoCreateTopics(boolean allowAutoCreateTopics)
Copyright © 2021. All rights reserved.