Batch jobs - prevent concurrency

563 Views Asked by At

I have several batch jobs running on a SAP Java system using SAP Java Scheduler. Unfortunately, I haven't come across any documentation that shows how to prevent concurrent executions for periodic jobs. All I've seen is "a new instance of the job will be executed at the next interval". This ruins my FIFO processing logic so I need to find a way to prevent it. If the scheduler API had a way of checking for the same job executions, this would be solved but haven't seen an example yet.

As a general architectural approach, other means to do this seems like using a DB table - an indicator table for marking current executions - or a JNDI parameter which would be checked first when the job starts. I could also "attempt" to use a static integer but that would fail me on clustered instances. The system is J2EE5 compliant and supports EJB 3.0, so a "singleton EJB" is not available either. I could set the max pool size for a bean and achieve a similar result maybe.

I'd like to hear your opinions on how to achieve this goal using different architectures.

Kind Regards,

S. Gökhan Topçu

1

There are 1 best solutions below

1
On

you can route the jobs to every node just like db sharding, and you can handle it just like running in one node.

or you have to use a center node, something like db or memory cache or zookeeper to prevent same job running on different nodes;