Announcement Announcement Module
No announcement yet.
Job level Transactionality in Spring Batch Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Job level Transactionality in Spring Batch

    I know right now there is no such thing as inter-step transactionality in Spring-Batch. I'm developing a complex batch job, with many steps performing several actions in database, and each one is related with the others, in such way that each one of them belongs to the same transaction. The way I understand the Spring-Batch paradigm I'm bound to use one-step job in order to have transactionality. Is there any thought (or any other way) to have some kind of job-level transactionality in lately or future versions?

    I also have considered one-step-only job to achieve transactionality. But this way you have to add all your business logic inside one (or more) processor(s). This way, I think you are not following the Spring-Batch concept, by adding all the process complexity in one step, and been confined to use DAOs in the processor to achieve your logic goals.

    I have been thinking that the clue could be in "TransactionManager" property, but still looking for the exact way.

    P.S: This link suggests me the possibility of using an envelope class with "@Transactional" annotation that will invoke my job and, therefore, shall have an external transaction.

  • #2
    Finally I have found a way to do this. As said in the last edition if you invoke the job from a transactional method:


    It's important set the propagation level to required in this level. And set the propagation in the job level to "mandatory", achieving with this the job and steps add their transactions to the current one. Nevertheless it's important to consider the potential volume size you are managing, in order to avoid out-of-the-limit commits or rollbacks.