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
A
KafkaListenerEndpoint providing the method to invoke to process
an incoming message for this endpoint.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.getBean()protected StringBuilderReturn a description for this endpoint.protected org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactoryReturn theMessageHandlerMethodFactory.voidSet 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.voidSet 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, getMainListenerId, getRecordFilterStrategy, getReplyTemplate, getResolver, getTopicPartitionsToAssign, getTopicPattern, getTopics, isAckDiscarded, isBatchListener, isSplitIterables, setAckDiscarded, setAutoStartup, setBatchListener, setBatchToRecordAdapter, setBeanFactory, setClientIdPrefix, setConcurrency, setConsumerProperties, setCorrelationHeaderName, setGroup, setGroupId, setId, setListenerInfo, setMainListenerId, setRecordFilterStrategy, setReplyHeadersConfigurer, setReplyTemplate, setSplitIterables, setTopicPartitions, setTopicPattern, setTopics, setupListenerContainer, toString
-
Constructor Details
-
MethodKafkaListenerEndpoint
public MethodKafkaListenerEndpoint()
-
-
Method Details
-
setBean
Set the object instance that should manage this endpoint.- Parameters:
bean- the target bean instance.
-
getBean
-
setMethod
Set the method to invoke to process a message managed by this endpoint.- Parameters:
method- the target method for thebean.
-
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
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
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.
-