How to use the IBM WebSphere work manager together with the Spring @Scheduled
annotation in my servlet?
Spring provides the WorkManagerTaskExecutor
. It allows to configure a work manager as described in the WebSphere docs or in this SO answer. However I don't see a relation to the @Scheduled
annotation and can't find any documentation how it works internally.
My goal is to configure scheduled tasks in a convenient way (as given by @Scheduled
) but I need the task threads created by the scheduler to be managed by WebSphere.
EDIT: In the original question I confused DefaultManagedTaskExecutor
with WorkManagerTaskExecutor
as the latter is deprecated in favor of the first. Now I understand that WorkManagerTaskExecutor
is Java EE 6 (and therefore required for our WebSphere 8.5 environment) whereas DefaultManagedTaskExecutor
belongs to Java EE 7 and can indeed be configured for @Scheduled
which is documented with the @EnableScheduling
annotation.
I can see what you mean that Spring documentation appears vague as to the relation between task executors that you configure and
@Scheduled
. Absent that sort of guarantee, you could verify observationally if scheduled tasks are running on WebSphere Application Server threads by printing the stack from one of your methods and confirming the presence ofcom.ibm.ws.*
packages. One easy way to do that is,Spring's
DefaultManagedTaskExecutor
is documented to rely onjava:comp/DefaultManagedExecutorService
, which requires Java EE 8 (or Jakarta EE) and ought to work with version 9 of WebSphere Application Server traditional. It should also work with WebSphere Application Server Liberty.If you are on 8.5.5 or earlier, you would need the
WorkManagerTaskExecutor
(referenced in one of the docs that you linked) which is based on the CommonJ WorkManager.