Package org.springframework.kafka.config
Class MethodKafkaListenerEndpoint<K,V>
- java.lang.Object
-
- org.springframework.kafka.config.AbstractKafkaListenerEndpoint<K,V>
-
- org.springframework.kafka.config.MethodKafkaListenerEndpoint<K,V>
-
- Type Parameters:
K- the key type.V- the value type.
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.InitializingBean,KafkaListenerEndpoint
- Direct Known Subclasses:
MultiMethodKafkaListenerEndpoint
public class MethodKafkaListenerEndpoint<K,V> extends AbstractKafkaListenerEndpoint<K,V>
AKafkaListenerEndpointproviding the method to invoke to process an incoming message for this endpoint.- Author:
- Stephane Nicoll, Artem Bilan, Gary Russell, Venil Noronha
-
-
Constructor Summary
Constructors Constructor Description MethodKafkaListenerEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected HandlerAdapterconfigureListenerAdapter(MessagingMessageListenerAdapter<K,V> messageListener)Create aHandlerAdapterfor this listener adapter.protected MessagingMessageListenerAdapter<K,V>createMessageListener(MessageListenerContainer container, MessageConverter messageConverter)Create aMessageListenerthat is able to serve this endpoint for the specified container.protected MessagingMessageListenerAdapter<K,V>createMessageListenerInstance(MessageConverter messageConverter)Create an emptyMessagingMessageListenerAdapterinstance.java.lang.ObjectgetBean()protected java.lang.StringBuildergetEndpointDescription()Return a description for this endpoint.protected org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactorygetMessageHandlerMethodFactory()Return theMessageHandlerMethodFactory.java.lang.reflect.MethodgetMethod()voidsetBean(java.lang.Object bean)Set the object instance that should manage this endpoint.voidsetErrorHandler(KafkaListenerErrorHandler errorHandler)Set theKafkaListenerErrorHandlerto invoke if the listener method throws an exception.voidsetMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)Set theMessageHandlerMethodFactoryto use to build theInvocableHandlerMethodresponsible to manage the invocation of this endpoint.voidsetMessagingConverter(org.springframework.messaging.converter.SmartMessageConverter messagingConverter)Set a spring-messagingSmartMessageConverterto convert the record value to the desired type.voidsetMethod(java.lang.reflect.Method method)Set the method to invoke to process a message managed by this endpoint.-
Methods inherited from class org.springframework.kafka.config.AbstractKafkaListenerEndpoint
afterPropertiesSet, getAutoStartup, getBatchListener, getBatchToRecordAdapter, getBeanExpressionContext, getBeanFactory, getBeanResolver, getClientIdPrefix, getConcurrency, getConsumerProperties, getGroup, getGroupId, getId, getListenerInfo, getRecordFilterStrategy, getRecoveryCallback, getReplyTemplate, getResolver, getRetryTemplate, getTopicPartitionsToAssign, getTopicPattern, getTopics, isAckDiscarded, isBatchListener, isSplitIterables, isStatefulRetry, setAckDiscarded, setAutoStartup, setBatchListener, setBatchToRecordAdapter, setBeanFactory, setClientIdPrefix, setConcurrency, setConsumerProperties, setGroup, setGroupId, setId, setListenerInfo, setRecordFilterStrategy, setRecoveryCallback, setReplyHeadersConfigurer, setReplyTemplate, setRetryTemplate, setSplitIterables, setStatefulRetry, setTopicPartitions, setTopicPattern, setTopics, setupListenerContainer, toString
-
-
-
-
Method Detail
-
setBean
public void setBean(java.lang.Object bean)
Set the object instance that should manage this endpoint.- Parameters:
bean- the target bean instance.
-
getBean
public java.lang.Object getBean()
-
setMethod
public void setMethod(java.lang.reflect.Method method)
Set the method to invoke to process a message managed by this endpoint.- Parameters:
method- the target method for thebean.
-
getMethod
public java.lang.reflect.Method getMethod()
-
setMessageHandlerMethodFactory
public void setMessageHandlerMethodFactory(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)
Set theMessageHandlerMethodFactoryto use to build theInvocableHandlerMethodresponsible to manage the invocation of this endpoint.- Parameters:
messageHandlerMethodFactory- theMessageHandlerMethodFactoryinstance.
-
setErrorHandler
public void setErrorHandler(KafkaListenerErrorHandler errorHandler)
Set theKafkaListenerErrorHandlerto invoke if the listener method throws an exception.- Parameters:
errorHandler- the error handler.- Since:
- 1.3
-
setMessagingConverter
public void setMessagingConverter(org.springframework.messaging.converter.SmartMessageConverter messagingConverter)
Set a spring-messagingSmartMessageConverterto convert the record value to the desired type. This will also cause theMessageHeaders.CONTENT_TYPEto be converted to String when mapped inbound.- Parameters:
messagingConverter- the converter.- Since:
- 2.7.1
-
getMessageHandlerMethodFactory
protected org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory getMessageHandlerMethodFactory()
Return theMessageHandlerMethodFactory.- Returns:
- the messageHandlerMethodFactory
-
createMessageListener
protected MessagingMessageListenerAdapter<K,V> createMessageListener(MessageListenerContainer container, @Nullable MessageConverter messageConverter)
Description copied from class:AbstractKafkaListenerEndpointCreate aMessageListenerthat is able to serve this endpoint for the specified container.- Specified by:
createMessageListenerin classAbstractKafkaListenerEndpoint<K,V>- Parameters:
container- theMessageListenerContainerto create aMessageListener.messageConverter- the message converter - may be null.- Returns:
- a
MessageListenerinstance.
-
configureListenerAdapter
protected HandlerAdapter configureListenerAdapter(MessagingMessageListenerAdapter<K,V> messageListener)
Create aHandlerAdapterfor this listener adapter.- Parameters:
messageListener- the listener adapter.- Returns:
- the handler adapter.
-
createMessageListenerInstance
protected MessagingMessageListenerAdapter<K,V> createMessageListenerInstance(@Nullable MessageConverter messageConverter)
Create an emptyMessagingMessageListenerAdapterinstance.- Parameters:
messageConverter- the converter (may be null).- Returns:
- the
MessagingMessageListenerAdapterinstance.
-
getEndpointDescription
protected java.lang.StringBuilder getEndpointDescription()
Description copied from class:AbstractKafkaListenerEndpointReturn a description for this endpoint.- Overrides:
getEndpointDescriptionin classAbstractKafkaListenerEndpoint<K,V>- Returns:
- a description for this endpoint.
Available to subclasses, for inclusion in their
toString()result.
-
-