Spring 两个数据库的批处理事务管理器

Spring batch transaction manager for two databases

我正在通过 Spring Batch 从一个数据库读取并写入另一个数据库。我需要两个事务管理器吗?我正在从第一个数据库读取 'n' 行,处理它们然后将 'm' 行写入第二个数据库。我正在使用 jdbc 但不是 JPA 或 Hibernate。

只有当目标数据源(我的意思是写入数据的地方)不同于数据源保存 SB 元数据表时,XA 才是必需的。如果目标数据库是同一个包含元数据表的数据库,则不需要 XA。
上瘾了,AbstractCursorItemReader为主,使用分离连接阅读。

By default the cursor will be opened using a separate connection. The ResultSet for the cursor is held open regardless of commits or roll backs in a surrounding transaction. Clients of this reader are responsible for buffering the items in the case that they need to be re-presented on a rollback. This buffering is handled by the step implementations provided and is only a concern for anyone writing their own step implementations.

(也看this question