A similar question was asked and answered in the spring forums when using the XML configuration:
http://forum.spring.io/forum/spring-projects/integration/723982-i-cant-figure-out-how-to-expose-task-executor-vai-jmx?p=724001#post724001
I would like to avoid using XML. I am using spring boot 1.1.4 and have included spring-boot-actuator. The My Application class is as follows:
@Configuration
@EnableAutoConfiguration
@ComponentScan
@EnableConfigurationProperties
public class Application {
@Bean
protected MBeanExporter mbeanExporter() {
MBeanExporter exporter = new MBeanExporter();
Map<String,Object> beans = new HashMap<>();
beans.put("org.springframework.boot:type=executor,name=taskExecutor", taskExecutor());
exporter.setBeans(beans);
return exporter;
}
@Bean
protected AsyncTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.setMaxPoolSize(200);
return executor;
}
}
source
share