3 Replies Latest reply on May 30, 2017 11:54 AM by James Perkins

    Stopping running tasks submitted to ManagedExecutorService upon server stop/shutdown

    Jørund Vier Skriubakken Newbie

      Hi.

       

      I'm having a singleton HA-timer, written exactly as in quickstart examples, which to speed up part's of it job submits several long running tasks (Callable) to the ManagedExecutorService.

       

      However upon stopping the server (I'm running Wildfly in domain mode) these long running tasks does not seem get interrupted by Wildfly. They just keep going and eventually holding the server back from shutting down.

      • I've tried making the Callable's implementing ManagedTaskListener, hoping Wildfly would invoke taskAborted, but without luck.
      • I've tried to cancel the futures returned from the ManagedExecutorService when the HATimerService stops, but the msc.service.Service.stop seems only to be invoked by Wildfly when all the submitted tasks are done .

       

      Desperately need help.

      How to detect server stop/shutdown interrupt any unfinished submitted tasks to ManagedExecutorService? It it possible at all? Am I on the wrong path with using the ManagedExecutorService?

       

      Thanks for any help!

       

      Jørund