Class DefaultDestinationTopicResolver
- java.lang.Object
-
- org.springframework.kafka.listener.KafkaExceptionLogLevelAware
-
- org.springframework.kafka.listener.ExceptionClassifier
-
- org.springframework.kafka.retrytopic.DefaultDestinationTopicResolver
-
- All Implemented Interfaces:
java.util.EventListener
,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
,DestinationTopicContainer
,DestinationTopicResolver
public class DefaultDestinationTopicResolver extends ExceptionClassifier implements DestinationTopicResolver, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Default implementation of the DestinationTopicResolver interface. The container is closed when aContextRefreshedEvent
is received and no more destinations can be added after that.- Since:
- 2.7
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultDestinationTopicResolver.DestinationTopicHolder
-
Constructor Summary
Constructors Constructor Description DefaultDestinationTopicResolver(java.time.Clock clock, org.springframework.context.ApplicationContext applicationContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDestinationTopics(java.util.List<DestinationTopic> destinationsToAdd)
Adds the provided destination topics to the container.DestinationTopic
getDestinationTopicByName(java.lang.String topic)
Returns the DestinationTopic instance registered for that topic.boolean
isContextRefreshed()
Return true if the application context is refreshed.void
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
DestinationTopic
resolveDestinationTopic(java.lang.String topic, java.lang.Integer attempt, java.lang.Exception e, long originalTimestamp)
Resolves the destination topic for the failed message.-
Methods inherited from class org.springframework.kafka.listener.ExceptionClassifier
addNotRetryableExceptions, addRetryableExceptions, defaultFalse, getClassifier, removeClassification, removeNotRetryableException, setClassifications
-
Methods inherited from class org.springframework.kafka.listener.KafkaExceptionLogLevelAware
getLogLevel, setLogLevel
-
-
-
-
Method Detail
-
resolveDestinationTopic
public DestinationTopic resolveDestinationTopic(java.lang.String topic, java.lang.Integer attempt, java.lang.Exception e, long originalTimestamp)
Description copied from interface:DestinationTopicResolver
Resolves the destination topic for the failed message.- Specified by:
resolveDestinationTopic
in interfaceDestinationTopicResolver
- Parameters:
topic
- the current topic for the message.attempt
- the number of processing attempts already made for that message.e
- the exception the message processing has thrownoriginalTimestamp
- the time when the first attempt to process the message threw an exception.- Returns:
- the
DestinationTopic
for the given parameters.
-
getDestinationTopicByName
public DestinationTopic getDestinationTopicByName(java.lang.String topic)
Description copied from interface:DestinationTopicContainer
Returns the DestinationTopic instance registered for that topic.- Specified by:
getDestinationTopicByName
in interfaceDestinationTopicContainer
- Parameters:
topic
- the topic name of the DestinationTopic to be returned.- Returns:
- the DestinationTopic instance registered for that topic.
-
addDestinationTopics
public void addDestinationTopics(java.util.List<DestinationTopic> destinationsToAdd)
Description copied from interface:DestinationTopicContainer
Adds the provided destination topics to the container.- Specified by:
addDestinationTopics
in interfaceDestinationTopicContainer
- Parameters:
destinationsToAdd
- theDestinationTopic
list to add.
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
-
isContextRefreshed
public boolean isContextRefreshed()
Return true if the application context is refreshed.- Returns:
- true if refreshed.
- Since:
- 2.7.8
-
-