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
I observed that wrong thread pool is used when I specify scheduler via scheduler parameter in @scheduled annotation.
package com.grainger.etl.jobs.config;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
@Slf4j
public class POC {
@Bean
public TaskScheduler xxxx() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(1);
threadPoolTaskScheduler.setThreadNamePrefix("xxxx");
return threadPoolTaskScheduler;
}
@Scheduled(fixedRate = 15, timeUnit = TimeUnit.SECONDS, scheduler = "xxxx")
public void scheduleX() {
log.info("Scheduled using xxxx thread pool {}", Thread.currentThread().getName());
}
@Bean
public TaskScheduler yyyy() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(1);
threadPoolTaskScheduler.setThreadNamePrefix("yyyy");
return threadPoolTaskScheduler;
}
@Scheduled(fixedRate = 15, timeUnit = TimeUnit.SECONDS, scheduler = "yyyy")
public void scheduleY() {
log.info("Scheduled using yyyy thread pool {}", Thread.currentThread().getName());
}
}
Output without datadog agent enabled:
2024-10-23T15:19:21.628+02:00 INFO 123249 --- [ xxxx1] com.grainger.etl.jobs.config.POC : Scheduled using xxxx thread pool xxxx1
2024-10-23T15:19:21.628+02:00 INFO 123249 --- [ yyyy1] com.grainger.etl.jobs.config.POC : Scheduled using yyyy thread pool yyyy1
Output with datadog enabled(-javaagent:/home/juri/projects/dd-java-agent.jar):
2024-10-23T15:20:55.253+02:00 INFO 125874 --- [pool-3-thread-1] com.grainger.etl.jobs.config.POC : Scheduled using xxxx thread pool pool-3-thread-1
2024-10-23T15:20:55.254+02:00 INFO 125874 --- [pool-3-thread-1] com.grainger.etl.jobs.config.POC : Scheduled using yyyy thread pool pool-3-thread-1
The text was updated successfully, but these errors were encountered:
I observed that wrong thread pool is used when I specify scheduler via scheduler parameter in @scheduled annotation.
Output without datadog agent enabled:
Output with datadog enabled(-javaagent:/home/juri/projects/dd-java-agent.jar):
The text was updated successfully, but these errors were encountered: