简体   繁体   English

使用 Quartz 和 spring 的配置

[英]Configuration whie using Quartz with spring

I am currently using quartz schedular which comes with spring framework.Our requirement is to schedule a method on daily basis which will call a webservice(only one method on the webservice).My configuration is as below.我目前正在使用 spring 框架附带的石英计划。我们的要求是每天安排一个方法,该方法将调用 Web 服务(Web 服务上只有一个方法)。我的配置如下。

<bean id="downloadJob" 
  class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">

    <property name="targetObject" ref="adapter" />
    <property name="targetMethod" value="getData" />

</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="jobDetails">
        <list>
        <ref bean="downloadJob" />

        </list>
    </property>

    <property name="triggers">
        <list>
        <ref bean="cronTrigger" />
        </list>
    </property>
</bean>

<bean id="cronTrigger"
    class="org.springframework.scheduling.quartz.CronTriggerBean">

    <property name="jobDetail" ref="downloadJob" />
    <property name="cronExpression" value="" /> 

</bean>

I am reading the cronExpression value from properties file.我正在从属性文件中读取 cronExpression 值。 Please provide me some pointers to implement the schedular in better way.请为我提供一些指示以更好地实施计划。 i have seen in some other projects where only using quartz with out spring.They are taking care of thread pool and some other properties as below.I am first time working on schedular implementation.Please provide me some suggestions/pointers on how to take care of these below properties while using quartz with spring(org.springframework.scheduling.quartz.SchedulerFactoryBean).Please suggest me if i need to take care of anyother things apart from these.我在其他一些项目中看到只使用没有 spring 的石英。他们正在处理线程池和其他一些属性,如下所示。我是第一次进行计划实施。请提供一些关于如何照顾的建议/指示在将石英与弹簧一起使用(org.springframework.scheduling.quartz.SchedulerFactoryBean)时,这些属性中的以下这些。如果我需要处理除这些之外的任何其他事情,请建议我。

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 15
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true

That's a fine way to implement a scheduler in Spring.这是在 Spring 中实现调度程序的好方法。 The Spring reference has a whole section on Quartz integration that should help get you started. Spring 参考有一个完整的关于石英集成的部分,应该可以帮助您入门。 For setting Quartz properties, use the SchedulerFactoryBean's quartzProperties property .要设置 Quartz 属性,请使用 SchedulerFactoryBean 的quartzProperties 属性 You'll have to decide yourself if there's anything else to take care of by reading up on Quartz in general and learning more about Quartz configuration .您必须通过阅读Quartz 的一般知识并了解有关Quartz 配置的更多信息来决定是否还有其他事情需要处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM