Class RecordMessagingMessageListenerAdapter<K,V>
java.lang.Object
org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter<K,V>
org.springframework.kafka.listener.adapter.RecordMessagingMessageListenerAdapter<K,V>
- Type Parameters:
K
- the key type.V
- the value type.
- All Implemented Interfaces:
AcknowledgingConsumerAwareMessageListener<K,
,V> ConsumerSeekAware
,GenericMessageListener<org.apache.kafka.clients.consumer.ConsumerRecord<K,
,V>> MessageListener<K,
V>
public class RecordMessagingMessageListenerAdapter<K,V>
extends MessagingMessageListenerAdapter<K,V>
implements AcknowledgingConsumerAwareMessageListener<K,V>
A
MessageListener
adapter that invokes a configurable HandlerAdapter
; used when the factory is
configured for the listener to receive individual messages.
Wraps the incoming Kafka Message to Spring's Message
abstraction.
The original ConsumerRecord
and
the Acknowledgment
are provided as additional arguments so that these can
be injected as method arguments if necessary.
- Author:
- Stephane Nicoll, Gary Russell, Artem Bilan, Venil Noronha
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter
MessagingMessageListenerAdapter.ReplyExpressionRoot
Nested classes/interfaces inherited from interface org.springframework.kafka.listener.ConsumerSeekAware
ConsumerSeekAware.ConsumerSeekCallback
-
Field Summary
Fields inherited from class org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter
logger, NULL_MESSAGE
-
Constructor Summary
ConstructorDescriptionRecordMessagingMessageListenerAdapter
(Object bean, Method method) RecordMessagingMessageListenerAdapter
(Object bean, Method method, KafkaListenerErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onMessage
(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> record, Acknowledgment acknowledgment, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) KafkaAcknowledgingConsumerAwareMessageListener
entry point.Methods inherited from class org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter
createMessagingErrorMessage, determineInferredType, getMessageConverter, getReplyHeadersConfigurer, getType, handleResult, invokeHandler, isConsumerRecordList, isConsumerRecords, isConversionNeeded, isMessageList, isSplitIterables, onIdleContainer, onPartitionsAssigned, onPartitionsRevoked, registerSeekCallback, sendResponse, setBeanResolver, setCorrelationHeaderName, setFallbackType, setHandlerMethod, setMessageConverter, setMessagingConverter, setReplyHeadersConfigurer, setReplyTemplate, setReplyTopic, setSplitIterables, toMessagingMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.kafka.listener.AcknowledgingConsumerAwareMessageListener
onMessage
Methods inherited from interface org.springframework.kafka.listener.ConsumerSeekAware
onFirstPoll, unregisterSeekCallback
Methods inherited from interface org.springframework.kafka.listener.GenericMessageListener
onMessage, onMessage
-
Constructor Details
-
RecordMessagingMessageListenerAdapter
-
RecordMessagingMessageListenerAdapter
public RecordMessagingMessageListenerAdapter(Object bean, Method method, @Nullable KafkaListenerErrorHandler errorHandler)
-
-
Method Details
-
onMessage
public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K, V> record, @Nullable Acknowledgment acknowledgment, org.apache.kafka.clients.consumer.Consumer<?, ?> consumer) KafkaAcknowledgingConsumerAwareMessageListener
entry point.Delegate the message to the target listener method, with appropriate conversion of the message argument.
- Specified by:
onMessage
in interfaceAcknowledgingConsumerAwareMessageListener<K,
V> - Specified by:
onMessage
in interfaceGenericMessageListener<K>
- Parameters:
record
- the incoming KafkaConsumerRecord
.acknowledgment
- the acknowledgment.consumer
- the consumer.
-