Spring,Quartz and JobStoreTX

By using CronTriggerBean i have created two triggers(say trigger A & B) for invoking two different action. We have placed our project as .war in 2 servers.I am using JobStoreTX for clustering. The problem i am facing is that i want to cluster only one trigger i.e A and trigger B should not be clustered. Is there a way to specify through code which trigger has to be clustered. My code goes on as below.

<bean id="shedulerJobStoreTX" class="org.quartz.impl.jdbcjobstore.JobStoreTX>
  <property name="driverDelegateClass" value="org.quartz.impl. jdbcjobstore.oracle.OracleDelegate">
<property name="dataSource" value ="jndiDS"/>
        <property name="tablePrefix" value="someschemaName"/>
        <property name="isClustered" value="true"/>
<property name="clusterCheckinInterval" value="${someValue}"/>
    </bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">       
        <property name="triggers">
            <list>
                <ref bean="cronTrigger" />
                <ref bean="clusterCronTrigger"/>
            </list>
        </property>
    </bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="runAppJob" />
        <property name="cronExpression" value="${someTimeValue1}"/>
    </bean>
    <bean id="clusterCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="runClusterJob" />
        <property name="cronExpression" value="${someTimeValue2}"/>
    </bean>

Hi, I have refined the code and the above said issue is not happening.PFB the code for the same.

  <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
                <list>
                    <ref bean="cronTrigger" />
                    <ref bean="clusterCronTrigger"/>
                </list>
            </property>
            <property name="quartzProperties">
            <props>
              <prop key="org.quartz.jobStore.isClustered">false</prop> 
              <prop key="org.quartz.scheduler.instanceId">AUTO</prop> 
              <prop key ="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.
   JobStoreTX </prop> 
              <prop key="org.quartz.jobStore.tablePrefix">schemaName</prop> 
              <prop key="org.quartz.jobStore.driverDelegateClass"> org.quartz.impl.jdbcjobstore.oracle.OracleDelegate</prop> 
              <prop key="org.quartz.jobStore.selectWithLockSQL"> SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME= ?</prop>
            </props>
            </property>
            <property name="dataSource" ref="fsmJndiDataSource"/> 

But the problem on executing the above code is that i am getting the below exception when the quartz is trying to get the lock ..."Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist"

Answers


Due to the message "ORA-00942: table or view does not exist", I think the table "schemaNameLOCKS" is missing. Indeed, from the doc:

org.quartz.jobStore.selectWithLockSQL

Must be a SQL string that selects a row in the "LOCKS" table and places a lock on the row. If not set, the default is "SELECT * FROM {0}LOCKS WHERE SCHED_NAME = {1} AND LOCK_NAME = ? FOR UPDATE", which works for most databases. The "{0}" is replaced during run-time with the TABLE_PREFIX that you configured above. The "{1}" is replaced with the scheduler's name.


you need to create required quartz tables in database before you run scheduler.

default quartz tables sql script is available at \docs\dbTables..

example if you are using quartz 2.2.1 distribution (quartz-2.2.1-distribution.tar\quartz-2.2.1\docs\dbTables\tables_oracle)

execute the sql script on database and make sure you see the tables created in it refer below image


Need Your Help

How to avoid repeated code?

c# asp.net code-reuse

I'm still quite new to programming and I noticed that I'm repeating code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.