Announcement Announcement Module
Collapse
No announcement yet.
Quartz with Spring not commiting Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Quartz with Spring not commiting

    I am using quartz, Spring with Hibernate as the JPA provider. Database is Oracle.

    I've got a method which writes a file to the file system and update the database with the details. This method can be called in two ways:
    1. Using a web service
    2. Or, as a scheduled quatrz job.


    I've set up quartz as:

    Code:
    <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false" scope="singleton">
            <property name="autoStartup" value="true"/>
            <property name="waitForJobsToCompleteOnShutdown" value="true"/>
            <property name="overwriteExistingJobs" value="true"/>
            <property name="dataSource" ref="dataSource"/>
            <property name="transactionManager" ref="transactionManager"/>
            <property name="quartzProperties">
                <props>
                    <prop key="org.quartz.scheduler.instanceName">FileScheduler</prop>
                    <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
                    <prop key="org.quartz.jobStore.misfireThreshold">6000</prop>
                    <prop key="org.quartz.jobStore.class">org.springframework.scheduling.quartz.LocalDataSourceJobStore</prop>
                    <prop key="org.quartz.jobStore.driverDelegateClass">${driverDelegateClass}</prop>
                    <prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
                    <prop key="org.quartz.jobStore.isClustered">true</prop>
                    <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
                    <prop key="org.quartz.threadPool.threadCount">5</prop>
                    <prop key="org.quartz.threadPool.threadPriority">5</prop>
                </props>
            </property>
    This method is using spring managed transaction.

    Problem is when this method is invoked by the quartz scheduler, the file gets created but the database is not updated (there should be two tables updated and one table insert).

    I've enabled hibernate show_SQL as well, but in case of scheduler no update\insert statements are getting logged.

    Though this works fine when this method is invoked by a web service request. Log shows update\insert statements as well.

    UPDATE 1

    To summarize my problem, this is what I am trying to achieve:
    1. Create a new record in the employee table.
    2. Save the employee_id in the job_store (quartz).
    3. When trigger is fired, quartz gives back the employee_id
    4. Retrieve (load) the employee record based on this key.
    5. Send Employee an email
    6. Update the Notification with status as 'Sent' (insert statement)


    In the end, I expect all the tables to be updated.

    When quartz triggers the job, all is working except point 6. Code is correct as when I invoke this method using a web service call, the table is getting updated.
    </bean>

  • #2
    Have you made your job transactional ?

    Comment

    Working...
    X