2 Replies Latest reply on Aug 25, 2014 10:51 AM by markus_s

    How to interrupt running tasks of a ManagedExecutorService after undeploy?

    markus_s

      I am trying to build a JAX-RS web service that uses ManagedExecutorService with WildFly 8.1 (see EE Concurrency Utilities - WildFly 8 - Project Documentation Editor) to execute some long-running tasks. These tasks should be interrupted after the web service is undeployed. Especially for running integration tests that would be important.

       

      The specification of JSR-236 (http://download.oracle.com/otndocs/jcp/concurrency-1_0-fr-eval-spec/index.html) says in section 3.1.6, that in case the ManagedExecutorService itself is shutdown (as when shutting down WildFly) all running tasks are interrupted - I can verify this behaviour.

      However, when I undeploy my application the ManagedExecutorService survives, and the now obsolete tasks of my undeployed application run until they finish - they never receive an interrupt.

      I checked this behaviour with logging Thread.currentThread().isInterrupted() in the task.

       

      Is there a way to interrupt (or even force-cancel) all running tasks belonging to a certain application when this application is undeployed?