简体   繁体   中英

Batchlet vs EJB Timer

I did an application to do some testing on network nodes like ping test, retrieve disk space ans so on.

I use a scheduled batchlet to run the actions but I wonder if it is the rigth use of batchlet?

Does an EJB timer should be more relevant? Also, when I run a batchlet, my glassfish server keeps a log of the batch job and I don't necessary need it (especially with the amount of batch jobs genereted during a day).

If I need to run some job in the same schedule time, I think batchled can do it but EJB timer too?

Could you give me your input on the rigth way to achieve this?

Thanks, Ersch

Using an EJB timer is appropriate when your task executes in an eye blink (or thereabouts).

Otherwise use the batching mechanism.

Long running tasks executed from EJB timers can be problematical because they execute in transactions which normally time out after a short period of time. Increasing this transaction time out also increases the chances of database and perhaps other resource locks which can impact normal operation of your application.

This isn't a question with a clear answer, but there is a bit of a cost in factoring your application as a batch job, and I would look at what I'm getting to see if it's worth doing so.

So you're thinking about a job consisting of a single Batchlet step. Well, there'd be nothing gained from "restart" functions, neither at the failing step within a job nor leveraging checkpoints within a chunk step. The batchlet programming model is quite simple... even if you really like @BatchProperty you'd have to deal with an XML now to do so.

This only starts to get more interesting if you want to start, view, and manage these executions along with the rest of your batch jobs. This might be because you're working with an implementation that offers some kind of implementation-specific add-on function. An example of this could be an integration with external scheduler software, allowing jobs to be scheduled by it. At the other extreme, if you found value in having a persisted record of all your batch job executions in one place (the job repository, usually a persistent DB), then that could also make this worthwhile for you.

But if you don't care for any of that, then an EJB timer could be the way to go instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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