spring - FileSplitter 完成后重命名文件

标签 spring spring-boot spring-integration

我目前正在 Spring Integration 中设计一个集成流程,其中我使用 FileSplitter 处理程序拆分文件并将结果发送到另一个服务。我目前正在使用 FileSystemPersistentAcceptOnceFileListFilter 处理“重复”文件,但我还想添加在使用 FileSplitter 读取文件后重命名文件的功能,最简单的实现方法是什么这个?

最佳答案

FileSplittermarkers 选项。这样它就会产生 STARTEND 消息。因此,当您收到 END 时,您可以执行所需的重命名逻辑:

Set to true to emit start/end of file marker messages before and after the file data. Markers are messages with FileSplitter.FileMarker payloads (with START and END values in the mark property). Markers might be used when sequentially processing files in a downstream flow where some lines are filtered. They enable the downstream processing to know when a file has been completely processed. In addition, a header file_marker containing START or END are added to these messages. The END marker includes a line count. If the file is empty, only START and END markers are emitted with 0 as the lineCount. Default: false. When true, apply-sequence is false by default. Also see markers-json.

有一个sample application具有类似的功能。

关于spring - FileSplitter 完成后重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44329918/

相关文章:

java - 字符串到 Json 转换器给出无效的 Json 值

java - AWS SDK 2 承担角色

java - Spring Integration,全局将无效消息转移到不同的目的地

spring - 在集合中查找元素,其中元素具有一个列表字段,并且给定值必须属于该列表

mysql - Spring Boot Jdbc Flyway 版本文件名 "V1__script.sql"不起作用,而是使用 "V1_file.sql"重命名文件正在起作用

Spring 启动两个对象映射器 bean

java - 为什么 WebMvcConfigurer 重写方法不起作用?

spring - 在运行时设置多个入站 channel 适配器

Spring Data JPA 对嵌套集合进行排序

json - Spring @ResponseBody 为原始类型生成无效的 JSON