RetryTopicConfigurationSupport produces exception: Either a RetryTopicSchedulerWrapper or TaskScheduler bean is required

huangapple go评论77阅读模式
英文:

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&lt;DeadLetterPublishingRecovererFactory&gt; configureDeadLetterPublishingContainerFactory() {

        return dlprf -&gt; 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.

huangapple
  • 本文由 发表于 2023年4月17日 15:37:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76032715.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定