简体   繁体   English

具有可选数据库写入的 Spring 批处理复合项目编写器

[英]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)用于多个目标的数据库的复合项目编写器(目前我有两个目标表,两个 jdbc 编写器)

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.现在的问题是,如果任何 jdbc 项目写入器由于条件不匹配或被跳过而未更新行,则此复合项目写入器将失败。

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所有 Item Writers 更新 - 没问题
  3. Some Writers needs to update and some needs to be skipped- need help to resolve this.有些 Writer 需要更新,有些需要跳过 - 需要帮助来解决这个问题。

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.有些 Writer 需要更新,有些需要跳过 - 需要帮助来解决这个问题。

If you need fine grained control like that, you need to create a custom writer.如果您需要这样的细粒度控制,则需要创建自定义编写器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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