views:

2477

answers:

5

It appears that our implementation of using Quartz - JDBCJobStore along with Spring, Hibernate and Websphere is throwing unmanaged threads.

I have done some reading and found a tech article from IBM stating that the usage of Quartz with Spring will cause that. They make the suggestion of using CommnonJ to address this issue.

I have done some further research and the only examples I have seen so far all deal with the plan old JobStore that is not in a database.

So, I was wondering if anyone has an example of the solution for this issue.

Thanks

+5  A: 

We have a working solution for this (two actually).

1) Alter the quartz source code to use a WorkManager daemon thread for the main scheduler thread. It works, but requires changing quarts. We didn't use this though since we didn't want maintain a hacked version of quartz. (That reminds me, I was going to submit this to the project but completely forgot)

2) Create a WorkManagerThreadPool to be used as the quartz threadpool. Implement the interface for the quartz ThreadPool, so that each task that is triggered within quartz is wrapped in a commonj Work object that will then be scheduled in the WorkManager. The key is that the WorkManager in the WorkManagerThreadPool has to be initialized before the scheduler is started, from a JEE thread (such as servlet initialization). The WorkManagerThreadPool must then create a daemon thread which will handle all the scheduled tasks by creating and scheduling the new Work objects. This way, the scheduler (on its own thread) is passing the tasks to a managed thread (the Work daemon).

Not simple, and unfortunately I do not have code readily available to include.

Robin
How about a 1 up for the answer 8-(
Robin
A: 

Check this article: http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html

basically, set the taskExecutor property on SchedulerFactoryBean to use a org.springframework.scheduling.commonj.WorkManager TaskExecutor which will use container managed threads.

A: 

@Robin - I realize this post is old but do you have an example of how you were able to either change Quartz to use a WorkManager daemon thread, or creating a WorkManagerThreadPool that can be used as the Quartz threadpool? I would like to use Quartz with Websphere but realize the limitations of unmanaged threads, and want to do it the "right way".

Thanks.

A: 

Hi,

You can check the below JIRA link raised on quartz regarding this.

http://jira.opensymphony.com/browse/QUARTZ-708

This has the required WebSphereThreadPool implementation which can be used with the changes in quartz.properties as mentioned to meet your requirements. Hope this helps.

Regards, Siva

Siva
A: 

You will have to use websphere's managed thread pools. You can do this via spring and commonj. CommonJ can has a task executor that will create managed threads. You can even use a reference to a jndi managed thread resource. You can then inject the commonj task executor into the Spring based Quartz SchedulerFactoryBean.

Please see http://boss.bekk.no/display/BOSS/Spring+Scheduling+in+WebSphere and scroll to "Quartz with CommonJ" section for more details.