[英]Spring Batch MultiResourceItemReader Chunk Commit Per Resource
I currently have a Spring Batch job that does the following: 我目前有一个执行以下任务的Spring Batch作业:
What I want is for each chunk to only contain lines from a single file resource so that the filename on the JMS message will link up to the corresponding file. 我想要的是每个块仅包含来自单个文件资源的行,以便JMS消息上的文件名将链接到相应的文件。
The problem is that when processing of one file resource is complete, the reader will just continue and process the next resource meaning that lines from multiple resource files are being inserted into the same chunk and the filename property will not necessarily match the underlying data in the chunk. 问题是,当完成一个文件资源的处理时,阅读器将继续处理下一个资源,这意味着将多个资源文件中的行插入到同一块中,并且filename属性不一定与该文件中的基础数据匹配。块。
Is there any clean way to prevent the reader from including lines from separate file resources in the same chunk? 有什么干净的方法可以防止阅读器在同一块中包含来自单独文件资源的行?
EDIT: I believe the solution will require using a custom chunk completion policy to somehow determine if the current item being read is from the same resource as the previous line, not sure how feasible this is though. 编辑:我相信解决方案将需要使用自定义块完成策略,以某种方式确定当前正在读取的项是否来自与上一行相同的资源,但不确定这样做是否可行。 Any thoughts?. 有什么想法吗?。
我将实现更改为使用MultiResourcePartitioner为每个文件创建一个分区步骤,现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.