Announcement Announcement Module
No announcement yet.
Multiple transaction in method write Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple transaction in method write


    I'm doing a batch with is parsing a flat file.
    For each line of this file I'm creating multiple objects.

    In the itemReader, i'd like to do this kind of process:
    - Call to a service "ServiceOne" which inserts an object in database (corresponding to the 10 first columns)
    - Then, call to another service "ServiceTwo" which inserts another object (kind of son of object created by "ServiceOne")

    For business reasons, I cannot do a whole service for all of this. That's why, process is divided in multiple services.
    All of this is done in the method write(). What I want is that, even if an Exception occured in "ServiceTwo", objects created by "ServiceOne" is going to be commited. But, as Spring Batch execute whole code of the methode in one transaction, everything is rollbacked.

    So, any ideas on how to do manage different transaction for each part of the code the method write() ?
    Thanks to help me.