背景信息
从一个数据库向另一个数据库迁移数据
migrate的实现使用了spring batch,通过分页的reader读数据,分页大小为500,每一个step的chunk size设置为了500,定义大致如下:
.listener(new BPStepListener(tenant))
.transactionManager(new DataSourceTransactionManager(detinationDataSource))
.<Map<String, Object>, Map<String, Object>>chunk(500)
.reader(buildItemReader(dataSource, table, tenant))
.processor(new CustomItemProcessor())
.writer(buildItemWriter(detinationDataSource, table, targetNameSpace))
.faultTolerant().skip(DuplicateKeyException.class).skipLimit(10)
.build();
在这个step定义当中chunk size设置为了500,也就意味着每读取,处理500条数据会向目标数据库写一次数据,即进行一次数据库提交。
上面是sprin