如何使用quartz simplethreadpool并行运行多个作业,只运行一个作业,另一个作业失败

时间:2018-04-20 14:07:42

标签: java spring quartz-scheduler

我创建了两个作业,都会生成excel文件。我需要并行生成多个xlsx。但是,一个人独自完成一项工作。

     <bean id="breakFileXlsxTwo"
            class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
            <property name="jobClass"
                value="com.citi.recon.quartz.BreakFileXlsxJobTwo" />
            <property name="durability" value="true" />
        </bean>
   <bean id="breakFileXlsxTwoTrigger" 
    class="com.citi.recon.quartz.PersistableCronTriggerFactoryBean">  
   <property name="jobDetail" ref="breakFileXlsxTwo" />  
   <property name="cronExpression" value="0 0/10 * * * ?"/>  
    </bean>

    <!-- cluster quartz, will only run in one server -->
    <bean id="clusterquartzScheduler"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="applicationContextSchedulerContextKey" value="applicationContext" />
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager" ref="txManager" />
        <property name="overwriteExistingJobs" value="true" />
        <property name="autoStartup" value="true" />
        <property name="quartzProperties">
            <props>
                <prop key="org.quartz.scheduler.instanceName">AMLReconQuartzScheduler</prop>
                <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
                <prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
                <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
                <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
                </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">30</prop>
                <prop key="org.quartz.threadPool.threadPriority">5</prop>
                <prop key="org.quartz.jobStore.useProperties">true</prop>
            </props>
        </property>
        <property name="jobFactory">
            <bean class="com.citi.recon.quartz.AutowiringSpringBeanJobFactory" />
        </property>
        <property name="jobDetails">
            <list>
                 <ref bean="userSynchJob"/>
                 <ref bean="breakFileDownloadJob"/>
                 <ref bean="breakFileXlsxTwo"/> 

            </list>
        </property>
        <property name="triggers">
            <list>
                 <ref bean="userSynchJobTrigger"/>
                 <ref bean="breakFileDownloadJobTrigger"/>
                 <ref bean="breakFileXlsxTwoTrigger"/>

            </list>
        </property>
    </bean>

在这两项工作中,我给出了相同的10分钟时间间隔。

在我的工作班中,我正在扩展QuartzJobBean,如下所示:

public class BreakFileXlsxDownloadJob extends QuartzJobBean

0 个答案:

没有答案