public class ConsumerProperties
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_POLL_TIMEOUT
The default
pollTimeout (ms). |
Constructor and Description |
---|
ConsumerProperties(java.util.regex.Pattern topicPattern)
Create properties for a container that will subscribe to topics matching the
specified pattern.
|
ConsumerProperties(java.lang.String... topics)
Create properties for a container that will subscribe to the specified topics.
|
ConsumerProperties(TopicPartitionOffset... topicPartitions)
Create properties for a container that will assign itself the provided topic
partitions.
|
Modifier and Type | Method and Description |
---|---|
java.time.Duration |
getAuthorizationExceptionRetryInterval() |
java.lang.String |
getClientId()
Return the client id.
|
org.apache.kafka.clients.consumer.OffsetCommitCallback |
getCommitCallback() |
LogIfLevelEnabled.Level |
getCommitLogLevel()
The level at which to log offset commits.
|
org.apache.kafka.clients.consumer.ConsumerRebalanceListener |
getConsumerRebalanceListener() |
java.lang.String |
getGroupId() |
java.util.Properties |
getKafkaConsumerProperties()
Get the consumer properties that will be merged with the consumer properties
provided by the consumer factory; properties here will supersede any with the same
name(s) in the consumer factory.
|
long |
getPollTimeout() |
java.time.Duration |
getSyncCommitTimeout() |
TopicPartitionOffset[] |
getTopicPartitionsToAssign() |
java.util.regex.Pattern |
getTopicPattern() |
java.lang.String[] |
getTopics() |
boolean |
isSyncCommits() |
protected java.lang.String |
renderProperties() |
void |
setAuthorizationExceptionRetryInterval(java.time.Duration authorizationExceptionRetryInterval)
Set the interval between retries after
AuthorizationException is thrown
by KafkaConsumer . |
void |
setClientId(java.lang.String clientId)
Set the client id; overrides the consumer factory client.id property.
|
void |
setCommitCallback(org.apache.kafka.clients.consumer.OffsetCommitCallback commitCallback)
Set the commit callback; by default a simple logging callback is used to log
success at DEBUG level and failures at ERROR level.
|
void |
setCommitLogLevel(LogIfLevelEnabled.Level commitLogLevel)
Set the level at which to log offset commits.
|
void |
setConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
Set the user defined
ConsumerRebalanceListener implementation. |
void |
setGroupId(java.lang.String groupId)
Set the group id for this container.
|
void |
setKafkaConsumerProperties(java.util.Properties kafkaConsumerProperties)
Set the consumer properties that will be merged with the consumer properties
provided by the consumer factory; properties here will supersede any with the same
name(s) in the consumer factory.
|
void |
setPollTimeout(long pollTimeout)
Set the max time to block in the consumer waiting for records.
|
void |
setSyncCommits(boolean syncCommits)
Set whether or not to call consumer.commitSync() or commitAsync() when the
container is responsible for commits.
|
void |
setSyncCommitTimeout(java.time.Duration syncCommitTimeout)
Set the timeout for commitSync operations (if
isSyncCommits() . |
java.lang.String |
toString() |
public static final long DEFAULT_POLL_TIMEOUT
pollTimeout
(ms).public ConsumerProperties(java.lang.String... topics)
topics
- the topics.public ConsumerProperties(java.util.regex.Pattern topicPattern)
topicPattern
- the pattern.CommonClientConfigs.METADATA_MAX_AGE_CONFIG
public ConsumerProperties(TopicPartitionOffset... topicPartitions)
topicPartitions
- the topic partitions.@Nullable public java.lang.String[] getTopics()
@Nullable public java.util.regex.Pattern getTopicPattern()
@Nullable public TopicPartitionOffset[] getTopicPartitionsToAssign()
public void setPollTimeout(long pollTimeout)
pollTimeout
- the timeout in ms; default 5000L.public long getPollTimeout()
public void setGroupId(java.lang.String groupId)
group.id
property
provided by the consumer factory configuration.groupId
- the group id.public java.lang.String getGroupId()
public java.lang.String getClientId()
setClientId(String)
public void setClientId(java.lang.String clientId)
clientId
- the client id.public void setConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
ConsumerRebalanceListener
implementation.consumerRebalanceListener
- the ConsumerRebalanceListener
instancepublic org.apache.kafka.clients.consumer.ConsumerRebalanceListener getConsumerRebalanceListener()
public void setSyncCommitTimeout(@Nullable java.time.Duration syncCommitTimeout)
isSyncCommits()
. Overrides
the default api timeout property.syncCommitTimeout
- the timeout.setSyncCommits(boolean)
public java.time.Duration getSyncCommitTimeout()
public void setCommitCallback(org.apache.kafka.clients.consumer.OffsetCommitCallback commitCallback)
syncCommits
is false.commitCallback
- the callback.setSyncCommits(boolean)
public org.apache.kafka.clients.consumer.OffsetCommitCallback getCommitCallback()
public void setSyncCommits(boolean syncCommits)
syncCommits
- true to use commitSync().setSyncCommitTimeout(Duration)
,
setCommitCallback(OffsetCommitCallback)
,
setCommitLogLevel(org.springframework.kafka.support.LogIfLevelEnabled.Level)
public boolean isSyncCommits()
public LogIfLevelEnabled.Level getCommitLogLevel()
public void setCommitLogLevel(LogIfLevelEnabled.Level commitLogLevel)
commitLogLevel
- the level.public java.util.Properties getKafkaConsumerProperties()
group.id
and client.id
are ignored.ConsumerConfig
,
setGroupId(String)
,
setClientId(String)
public void setKafkaConsumerProperties(java.util.Properties kafkaConsumerProperties)
group.id
and client.id
are ignored.
Property values must be String
s; only properties returned by
Properties.stringPropertyNames()
will be applied.kafkaConsumerProperties
- the properties.ConsumerConfig
,
setGroupId(String)
,
setClientId(String)
public java.time.Duration getAuthorizationExceptionRetryInterval()
public void setAuthorizationExceptionRetryInterval(java.time.Duration authorizationExceptionRetryInterval)
AuthorizationException
is thrown
by KafkaConsumer
. By default the field is null and retries are disabled.
In such case the container will be stopped.
The interval must be less than max.poll.interval.ms
consumer property.authorizationExceptionRetryInterval
- the duration between retriespublic java.lang.String toString()
toString
in class java.lang.Object
protected final java.lang.String renderProperties()