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:
Aware
,BeanFactoryAware
,InitializingBean
,KafkaListenerEndpoint
- Direct Known Subclasses:
MultiMethodKafkaListenerEndpoint
A
KafkaListenerEndpoint
providing the method to invoke to process
an incoming message for this endpoint.- Author:
- Stephane Nicoll, Artem Bilan, Gary Russell, Venil Noronha
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HandlerAdapter
configureListenerAdapter
(MessagingMessageListenerAdapter<K, V> messageListener) Create aHandlerAdapter
for this listener adapter.protected MessagingMessageListenerAdapter<K,
V> createMessageListener
(MessageListenerContainer container, MessageConverter messageConverter) Create aMessageListener
that is able to serve this endpoint for the specified container.protected MessagingMessageListenerAdapter<K,
V> createMessageListenerInstance
(MessageConverter messageConverter) Create an emptyMessagingMessageListenerAdapter
instance.getBean()
protected StringBuilder
Return a description for this endpoint.protected MessageHandlerMethodFactory
Return theMessageHandlerMethodFactory
.void
Set the object instance that should manage this endpoint.void
setErrorHandler
(KafkaListenerErrorHandler errorHandler) Set theKafkaListenerErrorHandler
to invoke if the listener method throws an exception.void
setMessageHandlerMethodFactory
(MessageHandlerMethodFactory messageHandlerMethodFactory) Set theMessageHandlerMethodFactory
to use to build theInvocableHandlerMethod
responsible to manage the invocation of this endpoint.void
setMessagingConverter
(SmartMessageConverter messagingConverter) Set a spring-messagingSmartMessageConverter
to convert the record value to the desired type.void
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, 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
Set theMessageHandlerMethodFactory
to use to build theInvocableHandlerMethod
responsible to manage the invocation of this endpoint.- Parameters:
messageHandlerMethodFactory
- theMessageHandlerMethodFactory
instance.
-
setErrorHandler
Set theKafkaListenerErrorHandler
to invoke if the listener method throws an exception.- Parameters:
errorHandler
- the error handler.- Since:
- 1.3
-
setMessagingConverter
Set a spring-messagingSmartMessageConverter
to convert the record value to the desired type. This will also cause theMessageHeaders.CONTENT_TYPE
to be converted to String when mapped inbound.- Parameters:
messagingConverter
- the converter.- Since:
- 2.7.1
-
getMessageHandlerMethodFactory
Return theMessageHandlerMethodFactory
.- Returns:
- the messageHandlerMethodFactory
-
createMessageListener
protected MessagingMessageListenerAdapter<K,V> createMessageListener(MessageListenerContainer container, @Nullable MessageConverter messageConverter) Description copied from class:AbstractKafkaListenerEndpoint
Create aMessageListener
that is able to serve this endpoint for the specified container.- Specified by:
createMessageListener
in classAbstractKafkaListenerEndpoint<K,
V> - Parameters:
container
- theMessageListenerContainer
to create aMessageListener
.messageConverter
- the message converter - may be null.- Returns:
- a
MessageListener
instance.
-
configureListenerAdapter
protected HandlerAdapter configureListenerAdapter(MessagingMessageListenerAdapter<K, V> messageListener) Create aHandlerAdapter
for this listener adapter.- Parameters:
messageListener
- the listener adapter.- Returns:
- the handler adapter.
-
createMessageListenerInstance
protected MessagingMessageListenerAdapter<K,V> createMessageListenerInstance(@Nullable MessageConverter messageConverter) Create an emptyMessagingMessageListenerAdapter
instance.- Parameters:
messageConverter
- the converter (may be null).- Returns:
- the
MessagingMessageListenerAdapter
instance.
-
getEndpointDescription
Description copied from class:AbstractKafkaListenerEndpoint
Return a description for this endpoint.- Overrides:
getEndpointDescription
in classAbstractKafkaListenerEndpoint<K,
V> - Returns:
- a description for this endpoint.
Available to subclasses, for inclusion in their
toString()
result.
-