This week's book giveaway is in the Testing forum. We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line! See this thread for details.
We have two batch jobs that are invoked concurrently at times in each of the cluster that do the same thing. We would like to ensure that only one of them id running at any given time.
Everytiem the job runs it creates an entry in the database logging in the timestamp it started running. The table has a running sequence# as a primary key. So what we see when the jobs run concurrently is 2 records with the same start timestamp. We are using EJB CMT on each of the nodes.
I would like to know how to ensure that one of them runs at any given time and the other one gracefully exits. I assume that the way to control is at the database level as they are concurrently trying to insert a record in the database. I assume that the solution will be using a combination of isolation level setting and pessimistic locking.
We are using Websphere 6.1 and UDB.