Rishi Singhal
Rishi Singhal

Reputation: 151

Holding Quartz scheduler to trigger job again till previous job finish processing

I am using Quartz scheduler to schedule the process of file download from SFTP. The job triggered after every 2 hrs. But sometimes due to huge file size, downloading takes more time and before it completes, the process is restarted. Is their any way we can hold the scheduler to trigger same job again till the previous process completes processing?

I m using quartz 1.8.5. Below is code

<flow name="quartzCronModel">
    <quartz:inbound-endpoint connector-ref="Quartz"
        jobName="cron-job" cronExpression="${database_download_timer}"
        encoding="UTF-8">
        <quartz:event-generator-job />
    </quartz:inbound-endpoint>
    <component doc:name="Download Database"
        class="com.org.components.sftp.FileTransfer">
        <method-entry-point-resolver
            acceptVoidMethods="true">
            <include-entry-point method="execute" />
        </method-entry-point-resolver>
    </component>
</flow>

I am reading cron expression from a properties file.

Upvotes: 0

Views: 1710

Answers (2)

mj. rahmati
mj. rahmati

Reputation: 75

It has been a long time since this question was asked. Jan Moravec has answered correctly, but during this time, this class has been deprecated. According to the Quartz documentation, It is currently best to use @DisallowConcurrentExecution and/or @PersistJobDataAfterExecution annotations instead. I hope it will be useful

Upvotes: 1

Jan Moravec
Jan Moravec

Reputation: 1880

Your job will need to implement the StatefulJob interface. It is a marker interface that tells Quartz that it should not trigger the job if it is still running. In other words it prevents concurrent executions of the job.

Upvotes: 2

Related Questions