【问题标题】:spring task:scheduled-tasks default scheduler pool sizespring task:scheduled-tasks 默认调度器池大小
【发布时间】:2016-08-01 12:43:22
【问题描述】:

我们正在使用 spring 的 task:scheduled-tasks 来根据 cron 表达式调度一个任务。我们的基本配置如下所示。我的问题是,由于我们没有提供对“task:scheduled-tasks”的调度程序的引用,它是如何工作的?它会自动生成什么样的默认配置?

<task:scheduled-tasks>
    <task:scheduled ref="runScheduler" method="run"
        cron="0 0/5 * * * ?" />
</task:scheduled-tasks>

【问题讨论】:

    标签: spring scheduled-tasks


    【解决方案1】:

    根据您的示例了解有关您的示例here 的更多信息。

    所有信息都在本文中进行了解释。

    但要恢复,进入您的配置:

    <task:scheduled-tasks>
    <task:scheduled ref="runScheduler" method="run"
        cron="0 0/5 * * * ?" />
    </task:scheduled-tasks>
    

    在“task:scheduled”中有一个引用 bean RunScheduler 的“ref”属性。 它可以通过以下方式声明:

    • XML配置文件,在本例中放入这个文件“resources/spring/batch/jobs/job-report”:

      &lt;bean id="runScheduler" class="com.mkyong.RunScheduler" /&gt;

    • 注释:

      @组件

      公共类 RunScheduler {

      ...
      

      }

    【讨论】:

    • 感谢 Sinouplen。但我的问题更多是关于在这个标签 " 中配置“调度程序”,这基本上是一个线程池。所以如果你不提供任何默认池的样子。就调度任务而言,对我来说效果很好。
    • 如果使用Spring Integration模块,默认调度器为SimpleTaskScheduler
    【解决方案2】:

    如果你使用Spring Integration,默认的任务调度器是explain here。 这是一个SimpleTaskScheduler

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 1970-01-01
      • 1970-01-01
      • 2020-08-19
      • 1970-01-01
      • 2021-08-18
      • 2020-05-23
      • 2022-08-20
      相关资源
      最近更新 更多