K - the key type.V - the value type.public class KafkaMessageListenerContainer<K,V> extends AbstractMessageListenerContainer<K,V>
Consumer supporting
auto-partition assignment or user-configured assignment.
With the latter, initial partition offsets can be provided.
AbstractMessageListenerContainer.AckModelogger| Constructor and Description |
|---|
KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory,
java.util.regex.Pattern topicPattern)
Construct an instance with the supplied configuration properties and topic
pattern.
|
KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory,
java.lang.String... topics)
Construct an instance with the supplied configuration properties and topics.
|
KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory,
org.apache.kafka.common.TopicPartition... topicPartitions)
Construct an instance with the supplied configuration properties and specific
topics/partitions - when using this constructor,
recentOffset can be specified. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
protected void |
doStop() |
java.util.Collection<org.apache.kafka.common.TopicPartition> |
getAssignedPartitions()
Return the
TopicPartitions currently assigned to this container,
either explicitly or by Kafka; may be null if not assigned yet. |
void |
setRecentOffset(long recentOffset)
Set the offset to this number of records back from the latest when starting.
|
getAckCount, getAckMode, getAckTime, getBeanName, getErrorHandler, getMessageListener, getPhase, getPollTimeout, getTaskExecutor, isAutoStartup, isRunning, setAckCount, setAckMode, setAckTime, setAutoStartup, setBeanName, setErrorHandler, setMessageListener, setPhase, setPollTimeout, setRunning, setTaskExecutor, setupMessageListener, start, stop, stoppublic KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory, org.apache.kafka.common.TopicPartition... topicPartitions)
recentOffset can be specified.consumerFactory - the consumer factory.topicPartitions - the topics/partitions; duplicates are eliminated.public KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory, java.lang.String... topics)
recentOffset is
ignored.consumerFactory - the consumer factory.topics - the topics.public KafkaMessageListenerContainer(ConsumerFactory<K,V> consumerFactory, java.util.regex.Pattern topicPattern)
recentOffset is
ignored.consumerFactory - the consumer factory.topicPattern - the topic pattern.public void setRecentOffset(long recentOffset)
recentOffset - the offset from the latest; default 0.public java.util.Collection<org.apache.kafka.common.TopicPartition> getAssignedPartitions()
TopicPartitions currently assigned to this container,
either explicitly or by Kafka; may be null if not assigned yet.TopicPartitions currently assigned to this container,
either explicitly or by Kafka; may be null if not assigned yet.protected void doStart()
doStart in class AbstractMessageListenerContainer<K,V>protected void doStop()
doStop in class AbstractMessageListenerContainer<K,V>