Callable tasks scheduled via a javax.enterprise.concurrent.ManagedScheduledExecutorService need to be queued when the server is suspended (this will not work see below in the "Implementation Details" as to why", This will not stop previously scheduled tasks from running or rescheduling themselves. Currently running tasks will also continue to run until completed.
- One idea is change the request-controller to queue java.util.concurrent.Callable rather than java.lang.Runnable. Runnables can be wrapped with a Executors.callable(runnable)
- The future returned would need to allow a way to set the actual future once the task is submitted
Other implementation ideas might come to light during the development phase. We need to work within the constraints for the reference implementation and ideally we don't want to try to replace portions of the reference implementation.
- When a server is suspended should any Triggers be wrapped and to throw a SkippedException while in a suspended state?
- Answer: No, this will be too unpredictable for users.
After testing various scenarios and possible issues this is not going to work how we had originally hoped. Any task requiring a java.util.concurrent.Future can't be queued as the Future.get() cannot block until the server is resumed. This could potentially block other requests attempting to gracefully shut down. Our best option at this point is to not make any changes to the current behavior. Tasks can still be scheduled, but will throw an exception when executed. Currently running scheduled tasks will also throw an exception when executed.