K
- the key type.V
- the value type.public abstract class AbstractAdaptableMessageListener<K,V> extends java.lang.Object implements MessageListener<K,V>, AcknowledgingMessageListener<K,V>
MessageListener
adapter providing the necessary infrastructure
to extract the payload of a Message
.MessageListener
,
AcknowledgingMessageListener
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger |
Constructor and Description |
---|
AbstractAdaptableMessageListener() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
extractMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
Extract the message body from the given Kafka message.
|
protected void |
handleListenerException(java.lang.Throwable ex)
Handle the given exception that arose during listener execution.
|
void |
onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
Kafka
MessageListener entry point. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onMessage
public void onMessage(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
MessageListener
entry point.
Delegate the message to the target listener method, with appropriate conversion of the message argument.
In case of an exception, the handleListenerException(Throwable)
method will be invoked.
onMessage
in interface MessageListener<K,V>
record
- the incoming Kafka ConsumerRecord
.handleListenerException(java.lang.Throwable)
,
AcknowledgingMessageListener.onMessage(ConsumerRecord, org.springframework.kafka.support.Acknowledgment)
protected void handleListenerException(java.lang.Throwable ex)
This method only applies when using a Kafka MessageListener
. With
AcknowledgingMessageListener
, exceptions get handled by the
caller instead.
ex
- the exception to handleonMessage(ConsumerRecord)