java - JBoss 5 调度后台任务。一个接一个地执行,打破了计划

标签 java jboss5.x scheduled-tasks

例如,我有两个任务:

  <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler">
    <attribute name="StartAtStartup">true</attribute>
    <attribute name="SchedulableClass">Scheduler1</attribute>
    <attribute name="InitialStartDate">NOW</attribute>
    <attribute name="SchedulePeriod">60</attribute>
    <attribute name="InitialRepetitions">-1</attribute>
    <attribute name="FixedRate">false</attribute>
  </mbean>

  <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler2">
    <attribute name="StartAtStartup">true</attribute>
    <attribute name="SchedulableClass">Scheduler2</attribute>
    <attribute name="InitialStartDate">NOW</attribute>
    <attribute name="SchedulePeriod">3600</attribute>
    <attribute name="InitialRepetitions">-1</attribute>
    <attribute name="FixedRate">false</attribute>
  </mbean>

即第一个每分钟安排一次,第二个每小时安排一次。

问题是,如果第二个任务的执行需要(比如说 5 分钟),那么第一个任务在此期间不会执行,而是会等到第二个任务完成。

有没有办法让它们并行工作?或者我应该转向 Quartz 或其他什么?

最佳答案

使用

<attribute name="TimerName">jboss:service=TimerNew</attribute>

它将并行启动计划。

关于java - JBoss 5 调度后台任务。一个接一个地执行,打破了计划,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10113274/

相关文章:

java - 在 Playframework 2.1 中测试预期渲染 View 的 Controller 操作

java - 安卓 HTTP : Make more than 1 asynctask request

java - 从数组中删除左侧重复项

hibernate - 尝试使用 Infinispan 作为 JPA/Hibernate 二级缓存提供程序,但没有成功

java - ScheduleAtFixedRate 未使用 Future java 8 提供输出

scheduled-tasks - 如何获取一堆 PBS Torque 作业的运行时间?

Java RMI : Rejecting requests when saturation is reached

java - 如何在 JBoss AS 5.1.0.GA 中配置 JDBC 数据源?

hibernate - 在 Wildfly 8.1 的 war 文件中使用自定义 JPA/Hibernate 提供程序

constraint-programming - 调度问题的约束编程框架