使用EJB 调度器怎么样?
否则,请在此处检查:
<mbean code="org.jboss.varia.scheduler.Scheduler" name="jboss.test:service=MyScheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">test.MySchedulable</attribute>
<attribute name="SchedulableArguments">MySchedulable,100</attribute>
<attribute name="SchedulableArgumentTypes">java.lang.String,long</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">5000</attribute>
<attribute name="InitialRepetitions">10</attribute>
</mbean>
可调度:
package test;
import java.util.Date;
import org.jboss.varia.scheduler.Schedulable;
import org.apache.log4j.Logger;
public class MySchedulable implements Schedulable
{
private static final Logger log = Logger.getLogger(MySchedulable.class);
private String name;
private long value;
public MySchedulable(String name, long value)
{
this.name = name;
this.value = value;
log.info("nt name: " + name + ", value: " + value);
}
public void perform(Date now, long repetitions)
{
log.info("perform(), time: " + now +", repetitions: " + repetitions +", name: " + name + ", value: " + value);
}
}