简体   繁体   English

ejb计时器服务vs cron

[英]ejb timer service vs cron

Ejb timer service can start some process in desired time intervals. Ejb计时器服务可以在所需的时间间隔内启动某些过程。
Also we can do the same thing with cron (min 1 minute) interval. 同样,我们可以按cron(至少1分钟)间隔执行相同的操作。

But doing it with cron we have more power on controlling, monitoring and changing the intervals. 但是使用cron进行操作时,我们在控制,监视和更改时间间隔方面拥有更大的能力。 Also we can restart if needed the cron very easily by command line. 如果需要,我们也可以通过命令行很容易地重新启动cron。 Also we can add or remove lines in the cron transparently. 我们也可以透明地添加或删除cron中的行。

What are the advantages of using ejb timer services over calling the ejbs from cron ? 与从cron调用ejbs相比,使用ejb计时器服务有什么优势?
(several lines of code in the cron classes are not a problem) (cron类中的几行代码不是问题)

Regards. 问候。

EJB Timers can be persistent and survive a crash: a missed timer will get triggered when the server is restarted. EJB计时器可以是持久性的,并且可以避免崩溃:重新启动服务器时,将触发错过的计时器。

Not sure how you could handle that if you cron an EJB client. 不知道如果您挂接EJB客户端该如何处理。

The cron timer will also fire if your application is not running while the EJB timers will be stopped. 如果您的应用程序没有运行而EJB计时器将停止,则cron计时器也会触发。 Also, you can do more complex operations from inside of your application than from cron. 而且,您可以从应用程序内部执行比cron更复杂的操作。

If you just need to run an external process with cron, then use cron. 如果只需要使用cron运行外部进程,则使用cron。

If you need to access internal data structures (copy data from/to a DB, send messages around, trigger events), then use an EJB timer. 如果您需要访问内部数据结构(从数据库复制数据到数据库,向数据库复制数据,向周围发送消息,触发事件),则可以使用EJB计时器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM