QuartzScheduler injection in JBoss AS 6

纵然是瞬间 提交于 2019-12-03 14:08:56

Despite extensive search in the Internet and several tests I didn't find a solution. I'm wondering why nobody else wants to have access to the Quartz-Scheduler inside JBoss.

I want to share a code snippet which is not the solution and not even a workaround, but it fit's my needs because I want periodically check some states and dynamically create a new Job.

@ResourceAdapter("quartz-ra.rar")
@MessageDriven(activationConfig = {
    @ActivationConfigProperty(propertyName = "cronTrigger",
                              propertyValue = "0 * * * * ?")})  
public class MyCronWatchDog implements Job  
{  
    public void execute(JobExecutionContext jex) throws JobExecutionException  
    {  
         System.out.println("Quartz job executed!!");
         Scheduler scheduler = jex.getScheduler();   
    }
}  

Can not use EJB3 TimerService instead? Create a session bean with timer service and call its schedule method

@Stateless
public class MySchedule implements MyScheduleRemote
{
    @Resource TimerService timerService;
    public void schedule ( Date date , ...)
    {
        timerService.createTimer( date, ..);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!