Spring Batch子任务处理

huangapple go评论57阅读模式
英文:

Spring Batch sub job processing

问题

有一个工作的Spring任务,其中包含一个单独的Tasklet。但是,我想对其进行重构并切换到多步骤任务。
我需要创建一个有序的文件,其中包含许多头部记录,包括用户信息,然后是用户的自定义信息,如地址和账单。

输出文件的结构如下:

r1: 用户信息
r2: 用户地址
r3: 用户账单1
r4: 用户账单2
r5: ...
r6: 用户账单N
r7: 用户2信息
r8: 用户2地址
r9: 用户2账单1
r10: 用户2账单2
r11: ...

用户信息、地址和用户账单分别来自3个不同的Postgres表。

在使用Steplets进行重构此项目时是否有任何更改,因为文件记录必须有序,并且每个用户的账单数量是未知的?
谢谢

英文:

I have a working spring job that contains a single Tasklet. However, I want to refactor it and switch to a multi-step job.
I need to create an ordered file with many header records containing users info followed by user custom information such as addresses and bills.

The output file is so structured:

r1:  user info
r2:  user addresses
r3:  user bill1
r4:  user bill2
r5:  ...
r6:  user billN
r7:  user2 info
r8:  user2 addresses
r9:  user2 bill1
r10: user2 biil2
r11: ...

The user info, address, and the user bills are retrieved from 3 different postgres tables.

Is there any change to refactoring this project using the Steplets since the file records must be ordered and the number of bills per user is unknown?
Thanks

答案1

得分: 1

这是一种常见的模式,详细描述在参考文档的驱动查询部分

这个思路是让你的项目读取器从用户表中读取记录,并添加一个项目处理器来为项目添加其他细节。

英文:

This is a common pattern and is described in the driving query section of the reference documentation.

The idea is to make your item reader read records from the user table, and add an item processor to enrich items with other details.

huangapple
  • 本文由 发表于 2023年3月12日 19:32:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75712829.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定