PDA

View Full Version : Verify quartz is properly configured with spring



motogp46
Jan 3rd, 2010, 04:37 PM
Hello,

I am in the process of intergrating Quartz with my Spring application. It will required the use of persistent jobs and thus Quartz will be configured to use the data source that the rest of my current Spring application is using.

Currently, my Spring application is configured with a jdbc data source, Hibernate and transactions. From an application standpoint, this is all working properly. By this I mean that we are a way into the application development where we have established services that communicate with the RDBMS, in this example Oracle, and entities are being created properly.

The app is divided into roughly 4 bundles:

1) database bundle - exposed the data source

2) dao bundle - defines the persistence unit and exposes out all the dao's for the entities

3) service bundle - the business logic and the transaction layer

4) web bundle - exposes out the web services and communicates with the service bundle to execute the web service operations.

Now, through a command line, I ran the oracle script that creates all the tables for Quartz with the same schema that my current application runs in.

I then modified by service bundle to instantiate a scheduler via the following bean:



<bean id="schedulerFactoryBean"
class="org.springframework.scheduling.quartz.SchedulerFac toryBean"
>
<property name="dataSource" ref="testDataSource"/>
<property name="schedulerName">
<value>
Testing123
</value>
</property>
<property name="transactionManager" ref="testTransactionManager"/>
</bean>


The data source and the transaction manager are the same ones used elsewhere in the service bundle and I know those are working properly.

Now, when i start up my application, it all seems to start up fine, i.e. no exceptions are thrown in any of the trace files.

But, when examining the QRTZ_SCHEDULER_STATE table, it's empty. I would have expected to see my Testing123 scheduler in there. Am I missing something?

I purposely haven't taken it any further and tried to schedule jobs or anything since I don't want to get to far and find out I am doing it wrong.

Anyways, if anybody knows what I may be doing wrong or if my expectation of seeing something in that table is incorrect please let me know.

Thanks!
Mauro

motogp46
Jan 4th, 2010, 09:30 AM
Well, I went forward with trying to create a job and trigger and that seemed to work properly. Records in other tables got created and updated as necessary. So it seems that it is hooked up properly via the settings above. Although, the QRTZ_SCHEDULER_STATE table still did not get updated with any records so I'm guessing it may only get updated if there are multiple schedulers or maybe if the default scheduler gets paused or something.

Mauro

MmarcoM
Jan 4th, 2010, 03:32 PM
Fun of 'The Doctor' ? ur nickname gives it away :)

ur quartz scheduler is configured correctly

if you want to have persistent jobs, your jobs need to imlement StatefulJob

Below is a link to a thread i started years ago when trying to do same things

http://forum.springsource.org/showthread.php?t=12837

hope it helps

rgds
marco

iwein
Jan 13th, 2010, 08:43 AM
If you just want scheduling, maybe you should toss quartz and use the scheduling support that comes with Spring 3.0.

JamesHoare
Jan 14th, 2010, 08:57 AM
Agreed, but wait until version 3.0.1 as there @Scheduled is currently registered twice in the current 3 release