JBoss Scheduler任务调度BUG之一

以前的系统架构为:jdk1.4+jboss4.0,在scheduler-service.xml配置文件中配置一个scheduler的标准代码如下:

<mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler">
  <attribute name="StartAtStartup">true</attribute>
  <attribute name="SchedulableClass">org.jboss.varia.scheduler.example.SchedulableExample</attribute>
  <attribute name="SchedulableArguments">Schedulabe Test,12345</attribute>
  <attribute name="SchedulableArgumentTypes">java.lang.String,int</attribute>
  <attribute name="InitialStartDate">0</attribute>
  <attribute name="SchedulePeriod">10000</attribute>
  <attribute name="InitialRepetitions">-1</attribute>  
</mbean>

最近,服务器升级,新的架构为:jdk5.0+jboss4.2,然后scheduler-service.xml得配置文件没有任何改动,出现了一个比较严重的问题,比如我设定调度器从午夜的12:00开始执行,在以前的架构下,每次都在12:00的时候开始执行,但是到新环境下,比如仍然是从12:00开始,执行任务的时间为1个小时,那么,下一次Scheduler启动的时间就在凌晨1点开始,再下一次则从凌晨2点开始。因为在半夜执行的任务都是批处理任务,相当耗性能,所以如果长时间不重新启动服务器,就可能导致业务繁忙的时候启动scheduler,这会给系统带来很大问题。调查了一段时间,终于在jboss的jira bug列表里面发现了这个问题,只需要改一下配置文件,配置如下:

<mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler">
  <attribute name="StartAtStartup">true</attribute>
  <attribute name="SchedulableClass">org.jboss.varia.scheduler.example.SchedulableExample</attribute>
  <attribute name="SchedulableArguments">Schedulabe Test,12345</attribute>
  <attribute name="SchedulableArgumentTypes">java.lang.String,int</attribute>
  <attribute name="InitialStartDate">0</attribute>
  <attribute name="SchedulePeriod">10000</attribute>
  <attribute name="InitialRepetitions">-1</attribute>
  <attribute name="FixedRate">true</attribute>    
</mbean>

也就是加入了倒数第二行"<attribute name="FixedRate">true</attribute>",导致这个问题的原因是jdk1.4和jdk5.0的Timer类在处理时间得时候发生了改变。所以需要加入这个参数让Scheduler按固定的启动时间运行。这也是JBoss4.2的一个Bug,Bug链接:https://jira.jboss.org/jira/browse/JBAS-328

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值