Results 1 to 2 of 2

Thread: Ability to wrap multiple steps in a transaction?

  1. #1
    Join Date
    May 2008
    Posts
    8

    Default Ability to wrap multiple steps in a transaction?

    Hello,

    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?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •