0

I have this background service, recently added to my stable spring boot application that gets packaged as war and runs under tomcat in prod environment.

@Component
@EnableScheduling

public class MonitoringService {

  @Autowired
  SomeService someService;

  @Scheduled(fixedRate = 15*60*1000, initialDelay=30*1000)
  public void runPerodically() {      
      performChecks();  

  }

  @Bean
  public TaskScheduler taskScheduler() {
    return new ConcurrentTaskScheduler(); 
  }  

}

Since this was added the tomcat seems behaving erratic and stuck at times and always produces thread dump when stopped such as

INFO: Destroying ProtocolHandler ["ajp-bio-0.0.0.0-8083"] 2017-09-06 21:43:54 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode):

"DestroyJavaVM" #119 prio=5 os_prio=0 tid=0x00007f3ef4529000 nid=0x6496 waiting on condition [0x0000000000000000] java.lang.Thread.State: RUNNABLE

"pool-7-thread-1" #67 prio=5 os_prio=0 tid=0x00007f3ea8653800 nid=0x7b28 waiting on condition [0x00007f3e9cf41000]

Are there any known issues with this approach or what is the right way to perform this task,

Mark1234
  • 589
  • 2
  • 8
  • 24
  • Is this working fine when you run it as standalone application? – Alain-Michel Chomnoue N Sep 07 '17 at 18:45
  • yes, locally it runs as spring boot and seem to work fine. – Mark1234 Sep 07 '17 at 18:49
  • 1
    I think there are two kind of situations, 1: the erratic behavior of tomcat without root cause, it could be related to `performChecks()` implementation . 2: the exception that you get when tomcat is stopped could be solved shutting down the task scheduler maybe this post could help https://stackoverflow.com/questions/6603051/how-can-i-shutdown-spring-task-executor-scheduler-pools-before-all-other-beans-i – Daniel C. Sep 07 '17 at 20:22
  • 1
    Your `@Bean` method and `@EnableScheduling` should be on a `@Configuration` class (or your Spring Boot bootstrap class) not on a regular component. – M. Deinum Sep 08 '17 at 08:23

0 Answers0