-
1. Re: Stopping running tasks submitted to ManagedExecutorService upon server stop/shutdown
jamezp May 9, 2017 4:51 PM (in response to jvskriubakken)The best solution is to keep a track of running jobs, use the returned Future, and have a @PreDestroy method that would cancel those running jobs.
--
James R. Perkins
-
2. Re: Stopping running tasks submitted to ManagedExecutorService upon server stop/shutdown
jvskriubakken May 29, 2017 5:04 AM (in response to jamezp)Hi and thanks for the follow up James!
My problem is that the @PreDestroy annotated method on my "Scheduler Bean" (written as quickstart/SchedulerBean.java at 9.x · wildfly/quickstart · GitHub , but with added @PreDestroy method) is not invoked before all submitted threads are finished.
Will any @PreDestroy in the application not be invoked until all submitted tasks to ManagedExecutorService is finished?
Would it help to use ManagedThreadFactory instead?
Would it help to listen to other events than "PreDestory"? What I see in the server log is the following log statement immediately after I issue stop on the server from the Wildfly admin console:
INFO [org.jboss.as.server] (ServerService Thread Pool -- 81) WFLYSRV0211: Suspending server
Thanks!
Jørund
-
3. Re: Stopping running tasks submitted to ManagedExecutorService upon server stop/shutdown
jamezp May 30, 2017 11:54 AM (in response to jvskriubakken)The @PreDestroy should be attached to the lifecycle of the EJB not any threads created from the EJB. The link you provide however is using a TimerService which may have different behavior than the ManagedExecutorService.
--
James R. Perkins