简体   繁体   中英

Spring batch composite item Writers with optional database writes

I have spring batch job which perform following steps

  1. Read from Database
  2. Process record and fetch relative details from other system
  3. Identify target data to be updated
  4. Composite item writer for database for multiple targets ( currently I have two targeted tables, two jdbc Writers)

Now the issue is this composite item writer fail if any of jdbc item writer don't update row due to condition is not matched or to be skipped.

Use case is

  1. Either all item Writers to be skipped- This is done by returning null object from processor
  2. All Item Writers updates - No issue
  3. Some Writers needs to update and some needs to be skipped- need help to resolve this.

The idea of wrapping each chunk in a transaction is to be able to process the whole chunk of items as a unit: either all items are committed or none of them is committed (all or nothing semantics).

Some Writers needs to update and some needs to be skipped- need help to resolve this.

If you need fine grained control like that, you need to create a custom writer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM