Jan 28th, 2010, 10:04 PM
Ability to wrap multiple steps in a transaction?
Say for example I have a job that consists of 10 steps.. Each step executes some SQL or a stored proc.
The job gets to say step 6 and something goes wrong, the entire job (steps 1-6) should effectively be rolled back.
Is this possible w/ spring batch?
Jan 29th, 2010, 03:35 AM
It's possible, but probably not recommended for everyday use, and the fall out from a failure may not be easy to diagnose - Batch jobs can run for extended periods, and holding a transaction open that long will always lead to a failure in the resource manager or remote server. If you want to try it, use a TaskletStep for each of the stored procs and set the transaction attributes to PROPAGATION_SUPPORTS. You also need to wrap the step sequence in a transaction, and there are several options you can try (I'd be interested to hear how it works out). Proxying Job.execute() will lead to the Job meta data not being cleanly updated on a failure, so that's probably not a good option. JobStep would work with a transactional Job (wrapping the whole Job in another Step in a wrapper Job). My first choice would be to use a FlowStep probably and make the Flow.start() transactional. There are other possibilities.