You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When @Configuration class implements SchedulingConfigurer #115
Hi, can you please try newest version 2.2.0 with annotation based config (as described in readme)? It should work better than ScheduledLockConfiguration. Please, let me know if it helps.
I actually had that annotation on there already but I also had the ScheduledLockConfiguration bean definition.
This still fails:
@Configuration
@EnableSchedulerLock(defaultLockAtMostFor = "PT30S")
@Slf4j
public class SchedulerConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar registrar) {
registrar.setTaskScheduler(taskScheduler()); (Line: 45)
}
@Bean(name = "taskExecutor")
@Primary
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(20);
executor.setThreadNamePrefix("traveliko-async-");
executor.setAllowCoreThreadTimeOut(true);
executor.setWaitForTasksToCompleteOnShutdown(true);
return executor;
}
@Bean(name = "taskScheduler")
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(50);
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setErrorHandler(t -> log.error(
"Unknown error occurred while executing task.", t
));
scheduler.setRejectedExecutionHandler(
(r, e) -> log.error(
"Execution of task {} was rejected for unknown reasons.", r
)
);
return scheduler;
}
}
java.lang.IllegalStateException: @Bean method SchedulerConfig.taskScheduler called as bean reference for type [org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler] but overridden by non-compatible bean instance of type [com.sun.proxy.$Proxy264]. Overriding bean of same name declared in: class path resource [com/traveliko/platform/core/config/SchedulerConfig.class]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:418) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:366) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at com.traveliko.platform.core.config.SchedulerConfig$$EnhancerBySpringCGLIB$$22cac23f.taskScheduler(<generated>) ~[classes/:na]
at com.traveliko.platform.core.config.SchedulerConfig.configureTasks(SchedulerConfig.java:45) ~[classes/:na]
Activity
lukas-krecan commentedon Dec 18, 2018
Hi, can you please try newest version 2.2.0 with annotation based config (as described in readme)? It should work better than ScheduledLockConfiguration. Please, let me know if it helps.
bjornharvold commentedon Dec 19, 2018
Hi @lukas-krecan
I actually had that annotation on there already but I also had the ScheduledLockConfiguration bean definition.
This still fails:
lukas-krecan commentedon Dec 19, 2018
You are right, it's indeed a bug. I will take a look at it in next few days. Thanks for reporting.
lukas-krecan commentedon Dec 19, 2018
Actually, there is an easy workaround, return type of
taskSchedulermethod should beTaskSchedulerand notThreadPoolTaskScheduler.bjornharvold commentedon Dec 19, 2018
Hi @lukas-krecan
That was indeed an oversight on my side. Not even a workaround ;-) That's the proper way to do it!
Thank you.
sanderdewinter commentedon May 8, 2019
Hi, I'm sorry to interrupt to use this closed issue.
I think I found some related issue on Stackoverflow which we do run into as well.
It might be due to the usage of the
messageBrokerTaskSchedulerbean defined inAbstractMessageBrokerConfiguration, or check the docs.Could you please shed some light on this?
lukas-krecan commentedon May 8, 2019
I have answered the SO question https://stackoverflow.com/questions/56017382/how-to-fix-websockets-and-shedlock-compatibility-in-spring-boot-application/56036601#56036601
sanderdewinter commentedon May 8, 2019
@lukas-krecan Thanks for you help! 👍