For the latest stable version, please use Spring for Apache Kafka 3.3.0!spring-doc.cn

Listener Container Properties

Table 1. ContainerProperties Properties
Property Default Description

ackCountspring-doc.cn

1spring-doc.cn

The number of records before committing pending offsets when the ackMode is COUNT or COUNT_TIME.spring-doc.cn

adviceChainspring-doc.cn

nullspring-doc.cn

A chain of Advice objects (e.g. MethodInterceptor around advice) wrapping the message listener, invoked in order.spring-doc.cn

ackModespring-doc.cn

BATCHspring-doc.cn

Controls how often offsets are committed - see Committing Offsets.spring-doc.cn

ackTimespring-doc.cn

5000spring-doc.cn

The time in milliseconds after which pending offsets are committed when the ackMode is TIME or COUNT_TIME.spring-doc.cn

assignmentCommitOptionspring-doc.cn

LATEST_ONLY _NO_TXspring-doc.cn

Whether or not to commit the initial position on assignment; by default, the initial offset will only be committed if the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG is latest and it won’t run in a transaction even if there is a transaction manager present. See the JavaDocs for ContainerProperties.AssignmentCommitOption for more information about the available options.spring-doc.cn

asyncAcksspring-doc.cn

falsespring-doc.cn

Enable out-of-order commits (see Manually Committing Offsets); the consumer is paused and commits are deferred until gaps are filled.spring-doc.cn

authExceptionRetryIntervalspring-doc.cn

nullspring-doc.cn

When not null, a Duration to sleep between polls when an AuthenticationException or AuthorizationException is thrown by the Kafka client. When null, such exceptions are considered fatal and the container will stop.spring-doc.cn

batchRecoverAfterRollbackspring-doc.cn

falsespring-doc.cn

Set to true to enable batch recovery, See After Rollback Processor.spring-doc.cn

clientIdspring-doc.cn

(empty string)spring-doc.cn

A prefix for the client.id consumer property. Overrides the consumer factory client.id property; in a concurrent container, -n is added as a suffix for each consumer instance.spring-doc.cn

checkDeserExWhenKeyNullspring-doc.cn

falsespring-doc.cn

Set to true to always check for a DeserializationException header when a null key is received. Useful when the consumer code cannot determine that an ErrorHandlingDeserializer has been configured, such as when using a delegating deserializer.spring-doc.cn

checkDeserExWhenValueNullspring-doc.cn

falsespring-doc.cn

Set to true to always check for a DeserializationException header when a null value is received. Useful when the consumer code cannot determine that an ErrorHandlingDeserializer has been configured, such as when using a delegating deserializer.spring-doc.cn

commitCallbackspring-doc.cn

nullspring-doc.cn

When present and syncCommits is false a callback invoked after the commit completes.spring-doc.cn

commitLogLevelspring-doc.cn

DEBUGspring-doc.cn

The logging level for logs pertaining to committing offsets.spring-doc.cn

consumerRebalanceListenerspring-doc.cn

nullspring-doc.cn

A rebalance listener; see Rebalancing Listeners.spring-doc.cn

commitRetriesspring-doc.cn

3spring-doc.cn

Set the number of retries RetriableCommitFailedException when using syncCommits set to true. Default 3 (4-attempt total).spring-doc.cn

consumerStartTimeoutspring-doc.cn

30sspring-doc.cn

The time to wait for the consumer to start before logging an error; this might happen if, say, you use a task executor with insufficient threads.spring-doc.cn

deliveryAttemptHeaderspring-doc.cn

falsespring-doc.cn

See Delivery Attempts Header.spring-doc.cn

eosModespring-doc.cn

V2spring-doc.cn

Exactly Once Semantics mode; see Exactly Once Semantics.spring-doc.cn

fixTxOffsetsspring-doc.cn

falsespring-doc.cn

When consuming records produced by a transactional producer, and the consumer is positioned at the end of a partition, the lag can incorrectly be reported as greater than zero, due to the pseudo record used to indicate transaction commit/rollback and, possibly, the presence of rolled-back records. This does not functionally affect the consumer but some users have expressed concern that the "lag" is non-zero. Set this property to true and the container will correct such mis-reported offsets. The check is performed before the next poll to avoid adding significant complexity to the commit processing. At the time of writing, the lag will only be corrected if the consumer is configured with isolation.level=read_committed and max.poll.records is greater than 1. See KAFKA-10683 for more information.spring-doc.cn

groupIdspring-doc.cn

nullspring-doc.cn

Overrides the consumer group.id property; automatically set by the @KafkaListener id or groupId property.spring-doc.cn

idleBeforeDataMultiplierspring-doc.cn

5.0spring-doc.cn

Multiplier for idleEventInterval that is applied before any records are received. After a record is received, the multiplier is no longer applied. Available since version 2.8.spring-doc.cn

idleBetweenPollsspring-doc.cn

0spring-doc.cn

Used to slow down deliveries by sleeping the thread between polls. The time to process a batch of records plus this value must be less than the max.poll.interval.ms consumer property.spring-doc.cn

idleEventIntervalspring-doc.cn

nullspring-doc.cn

When set, enables publication of ListenerContainerIdleEvents, see Application Events and Detecting Idle and Non-Responsive Consumers. Also see idleBeforeDataMultiplier.spring-doc.cn

idlePartitionEventIntervalspring-doc.cn

nullspring-doc.cn

When set, enables publication of ListenerContainerIdlePartitionEvents, see Application Events and Detecting Idle and Non-Responsive Consumers.spring-doc.cn

kafkaConsumerPropertiesspring-doc.cn

Nonespring-doc.cn

Used to override any arbitrary consumer properties configured on the consumer factory.spring-doc.cn

kafkaAwareTransactionManagerspring-doc.cn

nullspring-doc.cn

See Transactions.spring-doc.cn

listenerTaskExecutorspring-doc.cn

SimpleAsyncTaskExecutorspring-doc.cn

A task executor to run the consumer threads. The default executor creates threads named <name>-C-n; with the KafkaMessageListenerContainer, the name is the bean name; with the ConcurrentMessageListenerContainer the name is the bean name suffixed with -n where n is incremented for each child container.spring-doc.cn

logContainerConfigspring-doc.cn

falsespring-doc.cn

Set to true to log at INFO level all container properties.spring-doc.cn

messageListenerspring-doc.cn

nullspring-doc.cn

The message listener.spring-doc.cn

micrometerEnabledspring-doc.cn

truespring-doc.cn

Whether or not to maintain Micrometer timers for the consumer threads.spring-doc.cn

micrometerTagsspring-doc.cn

emptyspring-doc.cn

A map of static tags to be added to micrometer metrics.spring-doc.cn

micrometerTagsProviderspring-doc.cn

nullspring-doc.cn

A function that provides dynamic tags, based on the consumer record.spring-doc.cn

missingTopicsFatalspring-doc.cn

falsespring-doc.cn

When true prevents the container from starting if the configured topic(s) are not present on the broker.spring-doc.cn

monitorIntervalspring-doc.cn

30sspring-doc.cn

How often to check the state of the consumer threads for NonResponsiveConsumerEvent s. See noPollThreshold and pollTimeout.spring-doc.cn

noPollThresholdspring-doc.cn

3.0spring-doc.cn

Multiplied by pollTimeOut to determine whether to publish a NonResponsiveConsumerEvent. See monitorInterval.spring-doc.cn

observationConventionspring-doc.cn

nullspring-doc.cn

When set, add dynamic tags to the timers and traces, based on information in the consumer records.spring-doc.cn

observationEnabledspring-doc.cn

falsespring-doc.cn

Set to true to enable observation via Micrometer.spring-doc.cn

offsetAndMetadataProviderspring-doc.cn

nullspring-doc.cn

A provider for OffsetAndMetadata; by default, the provider creates an offset and metadata with empty metadata. The provider gives a way to customize the metadata.spring-doc.cn

onlyLogRecordMetadataspring-doc.cn

falsespring-doc.cn

Set to false to log the complete consumer record (in error, debug logs etc.) instead of just topic-partition@offset.spring-doc.cn

pauseImmediatespring-doc.cn

falsespring-doc.cn

When the container is paused, stop processing after the current record instead of after processing all the records from the previous poll; the remaining records are retained in memory and will be passed to the listener when the container is resumed.spring-doc.cn

pollTimeoutspring-doc.cn

5000spring-doc.cn

The timeout passed into Consumer.poll() in milliseconds.spring-doc.cn

pollTimeoutWhilePausedspring-doc.cn

100spring-doc.cn

The timeout passed into Consumer.poll() (in milliseconds) when the container is in a paused state.spring-doc.cn

restartAfterAuthExceptionsspring-doc.cn

falsespring-doc.cn

True to restart the container if it is stopped due to authorization/authentication exceptions.spring-doc.cn

schedulerspring-doc.cn

ThreadPoolTaskSchedulerspring-doc.cn

A scheduler on which to run the consumer monitor task.spring-doc.cn

shutdownTimeoutspring-doc.cn

10000spring-doc.cn

The maximum time in ms to block the stop() method until all consumers stop and before publishing the container stopped event.spring-doc.cn

stopContainerWhenFencedspring-doc.cn

falsespring-doc.cn

Stop the listener container if a ProducerFencedException is thrown. See After-rollback Processor for more information.spring-doc.cn

stopImmediatespring-doc.cn

falsespring-doc.cn

When the container is stopped, stop processing after the current record instead of after processing all the records from the previous poll.spring-doc.cn

subBatchPerPartitionspring-doc.cn

See desc.spring-doc.cn

When using a batch listener, if this is true, the listener is called with the results of the poll split into sub batches, one per partition. Default false.spring-doc.cn

syncCommitTimeoutspring-doc.cn

nullspring-doc.cn

The timeout to use when syncCommits is true. When not set, the container will attempt to determine the default.api.timeout.ms consumer property and use that; otherwise it will use 60 seconds.spring-doc.cn

syncCommitsspring-doc.cn

truespring-doc.cn

Whether to use sync or async commits for offsets; see commitCallback.spring-doc.cn

topics topicPattern topicPartitionsspring-doc.cn

n/aspring-doc.cn

The configured topics, topic pattern or explicitly assigned topics/partitions. Mutually exclusive; at least one must be provided; enforced by ContainerProperties constructors.spring-doc.cn

transactionManagerspring-doc.cn

nullspring-doc.cn

Deprecated since 3.2, see [kafkaAwareTransactionManager], Other transaction managers.spring-doc.cn

Table 2. AbstractListenerContainer Properties
Property Default Description

afterRollbackProcessorspring-doc.cn

DefaultAfterRollbackProcessorspring-doc.cn

An AfterRollbackProcessor to invoke after a transaction is rolled back.spring-doc.cn

applicationEventPublisherspring-doc.cn

application contextspring-doc.cn

The event publisher.spring-doc.cn

batchErrorHandlerspring-doc.cn

See desc.spring-doc.cn

Deprecated - see commonErrorHandler.spring-doc.cn

batchInterceptorspring-doc.cn

nullspring-doc.cn

Set a BatchInterceptor to call before invoking the batch listener; does not apply to record listeners. Also see interceptBeforeTx.spring-doc.cn

beanNamespring-doc.cn

bean namespring-doc.cn

The bean name of the container; suffixed with -n for child containers.spring-doc.cn

commonErrorHandlerspring-doc.cn

See desc.spring-doc.cn

DefaultErrorHandler or null when a transactionManager is provided when a DefaultAfterRollbackProcessor is used. See Container Error Handlers.spring-doc.cn

containerPropertiesspring-doc.cn

ContainerPropertiesspring-doc.cn

The container properties instance.spring-doc.cn

groupIdspring-doc.cn

See desc.spring-doc.cn

The containerProperties.groupId, if present, otherwise the group.id property from the consumer factory.spring-doc.cn

interceptBeforeTxspring-doc.cn

truespring-doc.cn

Determines whether the recordInterceptor is called before or after a transaction starts.spring-doc.cn

listenerIdspring-doc.cn

See desc.spring-doc.cn

The bean name for user-configured containers or the id attribute of @KafkaListeners.spring-doc.cn

listenerInfospring-doc.cn

nullspring-doc.cn

A value to populate in the KafkaHeaders.LISTENER_INFO header. With @KafkaListener, this value is obtained from the info attribute. This header can be used in various places, such as a RecordInterceptor, RecordFilterStrategy and in the listener code itself.spring-doc.cn

pauseRequestedspring-doc.cn

(read only)spring-doc.cn

True if a consumer pause has been requested.spring-doc.cn

recordInterceptorspring-doc.cn

nullspring-doc.cn

Set a RecordInterceptor to call before invoking the record listener; does not apply to batch listeners. Also see interceptBeforeTx.spring-doc.cn

topicCheckTimeoutspring-doc.cn

30sspring-doc.cn

When the missingTopicsFatal container property is true, how long to wait, in seconds, for the describeTopics operation to complete.spring-doc.cn

Table 3. KafkaMessageListenerContainer Properties
Property Default Description

assignedPartitionsspring-doc.cn

(read only)spring-doc.cn

The partitions currently assigned to this container (explicitly or not).spring-doc.cn

assignedPartitionsByClientIdspring-doc.cn

(read only)spring-doc.cn

The partitions currently assigned to this container (explicitly or not).spring-doc.cn

clientIdSuffixspring-doc.cn

nullspring-doc.cn

Used by the concurrent container to give each child container’s consumer a unique client.id.spring-doc.cn

containerPausedspring-doc.cn

n/aspring-doc.cn

True if pause has been requested and the consumer has actually paused.spring-doc.cn

Table 4. ConcurrentMessageListenerContainer Properties
Property Default Description

alwaysClientIdSuffixspring-doc.cn

truespring-doc.cn

Set to false to suppress adding a suffix to the client.id consumer property, when the concurrency is only 1.spring-doc.cn

assignedPartitionsspring-doc.cn

(read only)spring-doc.cn

The aggregate of partitions currently assigned to this container’s child KafkaMessageListenerContainers (explicitly or not).spring-doc.cn

assignedPartitionsByClientIdspring-doc.cn

(read only)spring-doc.cn

The partitions currently assigned to this container’s child KafkaMessageListenerContainers (explicitly or not), keyed by the child container’s consumer’s client.id property.spring-doc.cn

concurrencyspring-doc.cn

1spring-doc.cn

The number of child KafkaMessageListenerContainers to manage.spring-doc.cn

containerPausedspring-doc.cn

n/aspring-doc.cn

True if pause has been requested and all child containers' consumer has actually paused.spring-doc.cn

containersspring-doc.cn

n/aspring-doc.cn

A reference to all child KafkaMessageListenerContainers.spring-doc.cn