【问题标题】:Spring Batch Solution弹簧批处理解决方案
【发布时间】:2019-12-06 05:42:50
【问题描述】:
1
在我们的应用程序中,我们有大约 100000 个客户,并且需要每月处理一些数据。每个客户的数据处理逻辑涉及对不同服务的大约 7 次休息调用。我们需要在 Spring Batch 中执行此操作以实现性能。
处理数据的步骤--l
读取所有客户列表-获取数据网络服务--l
调用 7 个不同的微服务来获取余额、类型、费用、日期等。--l
将结果写入 S3 存储桶
请建议春季批次的设计流程
【问题讨论】:
标签:
spring-batch
batch-processing
spring-batch-tasklet
spring-batch-job-monitoring
spring-batch-stream
【解决方案1】:
您可以创建一个包含多个步骤的流程,您可以为每个步骤发送“serviceName”作为参数。编写一个基于 serviceName 调用服务的 customReader。在 CustomReader 中,您可以决定调用服务的方式。
List<Step> steps = new ArrayList<>();
for(each of your service){
createStep(String serviceName);
}
private Step createStep(String serviceName){
return stepBuilderFactory.get(""service calls")
.reader(UorCustomReader)
.processor(YourProcessor)//if needed
.writer(YourCustomCompositeWriter)
}