简体   繁体   中英

Exclusive batch jobs with javax.batch/jsr352

We have an application which does a lot of imports and exports - basically between CSV files and database tables.

Some of the imports and exports are conflicting (you can't execute them simultaneously) for various reasons (like "legacy code").

We were looking into javax.batch . Conceptually it suits very well. But what we really failed to find is the possibility to somehow manage the "exclusiveness" of certain jobs we want to run.

Could someone please provide a pointer on that? How would we implement exclusive batch jobs with javax.batch ? Or should we implement our own JobOperator for this?

Update

What I mean by "exclusiveness" is tha ability to define that certain jobs may not be executed in parallel. In the most trivial case this would mean "only execute one an only one job at time". In more complex cases more complex logic like "job of type A can't run with other jobs of type A or B, but C is OK". The "type of job" is, for instance, jobXmlName here (regardless of job parameters).

JSR-352 (and Spring Batch) both avoid the topic of orchestration on purpose. To do so would require a particular approach which prevents the inherent flexibility these batch frameworks offer. Because of that, the JobOperator in JSR-352 does not have any notion of preventing one job from running while another one is running.

While you could accomplish this via your own custom JobOperator , I wouldn't recommend that approach. Instead, you'd be better off moving that one layer higher, into whoever is calling the JobOperator so that the logic for that type of orchestration concern is separated from the implementation details of launching a job. For example, if you're using a scheduler to launch jobs, I'd put the logic there as to what jobs can run in parallel and which ones cannot...not in a custom JobOperator .

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