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>
AKafkaListenerEndpoint
providing the method to invoke to process an incoming message for this endpoint.
-
-
Constructor Summary
Constructors Constructor Description MethodKafkaListenerEndpoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.java.lang.Object
getBean()
protected java.lang.StringBuilder
getEndpointDescription()
Return a description for this endpoint.protected org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory
getMessageHandlerMethodFactory()
Return theMessageHandlerMethodFactory
.java.lang.reflect.Method
getMethod()
void
setBean(java.lang.Object bean)
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(org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory messageHandlerMethodFactory)
Set theMessageHandlerMethodFactory
to use to build theInvocableHandlerMethod
responsible to manage the invocation of this endpoint.void
setMessagingConverter(org.springframework.messaging.converter.SmartMessageConverter messagingConverter)
Set a spring-messagingSmartMessageConverter
to convert the record value to the desired type.void
setMethod(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 theMessageHandlerMethodFactory
to use to build theInvocableHandlerMethod
responsible to manage the invocation of this endpoint.- Parameters:
messageHandlerMethodFactory
- theMessageHandlerMethodFactory
instance.
-
setErrorHandler
public void setErrorHandler(KafkaListenerErrorHandler errorHandler)
Set theKafkaListenerErrorHandler
to 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-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
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: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
protected java.lang.StringBuilder 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.
-
-