Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

Using batch mode in Quartz

With the intent to improve performance of quartz, I intend to use batching in quartz as suggested in Performance Tuning on Quartz Scheduler

We create our quartz scheduler in integration with spring as below.

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <!-- Quartz requires a separate 'quartz.properties' file -->
        <property name="configLocation" value="classpath:/quartz.properties"/>

        <!-- Naturally, Quartz with the DB requires references
              to the data source and transaction manager beans -->
        <property name="dataSource" ref="quartzDataSource"/>
        <!--<property name="transactionManager" ref="transactionManager"/>-->

        <!-- reference to our 'autowiring job factory bean', defined above: -->
        <property name="jobFactory" ref="quartzJobFactory"/>

        <!-- Boolean controlling whether you want to override
              the job definitions in the DB on the app start up.
              We'll talk about it more in the next section. -->
        <property name="overwriteExistingJobs" value="true"/>

        <!-- I will not explain the next three properties, just use it as shown: -->
        <property name="autoStartup" value="${isQuartzEnabled}" />
        <property name="schedulerName" value="quartzScheduler"/>
        <property name="applicationContextSchedulerContextKey" value="applicationContext"/>

        <!-- Controls whether to wait for jobs completion on app shutdown, we use 'true' -->
        <property name="waitForJobsToCompleteOnShutdown"
                  value="true"/>

        <!-- Tell the Quartz scheduler about the triggers.
              We have implemented the 'quartzTriggers' bean in the 'Jobs and triggers' section.
              No need to pass job definitions, since triggers created via Spring know their jobs.
              Later we'll see a case when we'll have to disable this and pass the jobs explicitly.-->
        <property name="triggers" ref="quartzTriggers"/>

    </bean>

How do I specify maxBatchSize & batchTimeWindow of createScheduler in DirectSchedulerFactory ?

Upvotes: 6

Views: 3949

Answers (2)

jebeaudet
jebeaudet

Reputation: 1603

  • org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow will set the batchTimeWindow.
  • org.quartz.scheduler.batchTriggerAcquisitionMaxCount will set the maxBatchSize property.

Source : https://github.com/quartz-scheduler/quartz/blob/master/quartz-core/src/main/java/org/quartz/impl/StdSchedulerFactory.java

Upvotes: 0

Vinod Jayachandran
Vinod Jayachandran

Reputation: 3898

I found that we can achieve by configuring the below property in quartz.properties file

org.quartz.scheduler.batchTriggerAcquisitionMaxCount

Reference : Configure Main Scheduler Settings

Upvotes: 5

Related Questions