[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Messages posted by: whosrod  XML
Profile for whosrod -> Messages posted by whosrod [1]
Author Message
I'm experiencing some strange issues related to Quartz and Spring transactions. I'm using SchedulerFactoryBean with a local PostgreSQL database. The problem is that immediate jobs aren't firing immediately when the scheduleJob() call is in a larger Spring transaction.

For example, the following code executes the job immediately:
Code:
 JobDetail jobDetail = new JobDetail("testping", PingJob.class);
 Trigger trigger = new SimpleTrigger("testping", new Date());
 jobScheduler.scheduleJob(jobDetail, trigger);
 


This code, however, delays the job execution for a few seconds (max of 30 seconds):
Code:
 DefaultTransactionDefinition def = new DefaultTransactionDefinition();
 TransactionStatus status = txManager.getTransaction(def);
 try {
 	JobDetail jobDetail = new JobDetail("testping", PingJob.class);
 	Trigger trigger = new SimpleTrigger("testping", new Date());
 	jobScheduler.scheduleJob(jobDetail, trigger);
 	txManager.commit(status);
 } catch (Exception e) {
 	txManager.rollback(status);
 }
 


This page "http://www.quartz-scheduler.org/docs/configuration/ConfigMain.html" showed me how to modify the delay in fire time via "org.quartz.scheduler.idleWaitTime", but that incurs a performance cost on my app. That page also mentions that that property shouldn't have to be modified unless XA transactions are being used, which I don't believe my app is using (local database).

So what am I doing wrong? Any help or insight would be most appreciated :)

Scheduler bean:
Code:
 <bean id="jobScheduler"
 		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 		<property name="dataSource" ref="dataSource" />
 		<property name="transactionManager" ref="transactionManager" />
 		<property name="quartzProperties">
 			<value>
 				org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
 				org.quartz.jobStore.tablePrefix = QRTZ_
 			</value>
 		</property>
 		<property name="jobFactory">
 			<bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" />
 		</property>
 		<property name="schedulerContextAsMap">
 			<map>
 			    <entry key="dataSource" value-ref="dataSource" />
 				<entry key="jobDao" value-ref="jobDao" />
 				<entry key="transactionManager" value-ref="transactionManager" />
 			</map>
 		</property>
 	</bean>
 


DB bean:
Code:
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
 		<property name="driverClassName" value="org.postgresql.Driver" />
 		<property name="url" value="jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}" />
 		<property name="username" value="${DB_USER}" />
 		<property name="password" value="${DB_PASS}" />
 		<property name="defaultAutoCommit" value="true" />
 		<property name="maxIdle" value="1" />
 	</bean>
 


TxManager bean:
Code:
 	<bean id="transactionManager"
 		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
 		<property name="dataSource" ref="dataSource" />
 	</bean>
 
Profile for whosrod -> Messages posted by whosrod [1]
Go to:   
Powered by JForum 2.1.7 © JForum Team