如何安排JBoss任务?
我在JBoss中安排了任务:如何安排JBoss任务?,jboss,scheduled-tasks,Jboss,Scheduled Tasks,我在JBoss中安排了任务: <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="org.jboss.varia.scheduler.Scheduler" name="acme:service=Scheduler"> <attribute name="...">...</attribute> ..... </mbean>
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.varia.scheduler.Scheduler" name="acme:service=Scheduler">
<attribute name="...">...</attribute>
.....
</mbean>
</server>
...
.....
如何编写此任务,它将在每个月的第一天凌晨1:00执行?
谢谢大家! 您需要创建一个调度类 因为您希望每月执行一次,并且不能将其作为属性进行说明。您需要另一个类来处理设置下一个间隔 让调度器类调用每月计时器来获取下一个间隔并设置它。可能在初始开始时传递一些值
<mbean code="org.jboss.varia.scheduler.Scheduler"
name="jboss.docs:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">org.jboss.book.misc.ex2.ExSchedulable</attribute>
<attribute name="SchedulableArguments">01:00</attribute> <!-- 24hr time hh:mm -->
<attribute name="SchedulableArgumentTypes">java.lang.String</attribute>
</mbean>
public ExSchedulable(String time) {
Date tDate = new Date();
tDate.setTime(time);
Monthly monthyObj = Monthly(1); //Day of the month
//Gets the next interval date specified from the day of the month
Date nextInterval = monthyObj .getNextInterval(tDate);
}