使用Schedule Expression参数化EJB Scheduler

使用Schedule Expression参数化EJB Scheduler,第1张

使用Schedule Expression参数化EJB Scheduler

而是使用程序化调度,这是一个示例

@Singleton@Startuppublic class TriggerJob{    @EJB    //some injections    @Resource    private TimerService timerService;    @PostConstruct    public void init() {        createTimer();        //the following pre resolve my startup problem        try {        preparation();        } catch (CertificateVerificationException e) { e.printStackTrace();        }    }    @Timeout    public void timerTimeout() {        try {        preparation();        } catch (CertificateVerificationException e) {        e.printStackTrace();        }    }    private void createTimer() {        Scheduleexpression scheduleexpression = new Scheduleexpression();        scheduleexpression.second("30").minute("*/5").hour("*");        TimerConfig timerConfig = new TimerConfig();        timerConfig.setPersistent(false);        timerService.createCalendarTimer(scheduleexpression, timerConfig);        }    public void preparation(){        // my scheduled tasks    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5055262.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存