英文:
RetryTopicConfigurationSupport produces exception: Either a RetryTopicSchedulerWrapper or TaskScheduler bean is required
问题
I'm using Spring Boot 3.0.5 with Spring Kafka. I want to configure Non-Blocking topics with RetryTopicConfigurationSupport, as it is written here: https://docs.spring.io/spring-kafka/reference/html/#retry-topic-global-settings
My configuration looks as follows:
@EnableKafka
@Configuration
public class RetryTopicsConfig extends RetryTopicConfigurationSupport {
@Override
protected Consumer<DeadLetterPublishingRecovererFactory> configureDeadLetterPublishingContainerFactory() {
return dlprf -> dlprf.setRetainAllRetryHeaderValues(false);
}
}
When application starts, it produces:
Caused by: java.lang.IllegalArgumentException: Either a RetryTopicSchedulerWrapper or TaskScheduler bean is required
Am I doing something wrong?
When I added:
@Bean
public TaskScheduler taskScheduler() {
return new ThreadPoolTaskScheduler();
}
it starts, but I'm not sure if I suppose to do that? According to documentation (https://docs.spring.io/spring-kafka/reference/html/#programmatic-construction) it is designed for Progammatic Construction, but I use annotations.
英文:
I'm using Spring Boot 3.0.5 with Spring Kafka. I want to configure Non-Blocking topics with RetryTopicConfigurationSupport, as it is written here:
https://docs.spring.io/spring-kafka/reference/html/#retry-topic-global-settings
My configuration looks as follows:
@EnableKafka
@Configuration
public class RetryTopicsConfig extends RetryTopicConfigurationSupport {
@Override
protected Consumer<DeadLetterPublishingRecovererFactory> configureDeadLetterPublishingContainerFactory() {
return dlprf -> dlprf.setRetainAllRetryHeaderValues(false);
}
}
When application starts, it produces:
Caused by: java.lang.IllegalArgumentException: Either a RetryTopicSchedulerWrapper or TaskScheduler bean is required
Am I doing something wrong?
When I added:
@Bean
public TaskScheduler taskScheduler() {
return new ThreadPoolTaskScheduler();
}
it starts, but I'm not sure if I suppose to do that? According to documentation (https://docs.spring.io/spring-kafka/reference/html/#programmatic-construction) it is designed for Progammatic Construction, but I use annotations.
答案1
得分: 2
我认为在RetryTopicsConfig.class
的类级别上添加@EnableScheduling
在这种情况下更好。
英文:
I think adding the @EnableScheduling
at the class level of the RetryTopicsConfig.class
is much better in this case
答案2
得分: 0
在这种情况下,是的,只需定义一个TaskScheduler
bean。
英文:
In this case, yes, it is fine to just define a TaskScheduler
bean.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论