Spring Integration DSL: Dealing with FileSplitter START/END marker payloads

☆樱花仙子☆ 提交于 2020-01-15 05:16:49

问题


I want to setup an integration flow like this:

    return IntegrationFlows
            .from("inputChannel")
            .split(fileSplitter)
            .handle(this::doStuff1)
            .handle(this::doStuff2)
            .handle(this::doStuff3)
            .aggregate()
            .handle(this::deleteFile)

FileSplitter:

@Bean
public FileSplitter fileSplitter() {
    FileSplitter fileSplitter = new FileSplitter(true, true);
    fileSplitter.setCharset(StandardCharsets.UTF_8);
    fileSplitter.setApplySequence(true);
    return fileSplitter;
}

Input is of type File. The file size is big, so I want to stream the contents line by line, process them and delete the file at the end. The problem is now I have to check and ignore the file SOF,EOF marker payloads in all the handler methods along the chain. Is there a different way without checking the types in each doStuff methods? (I think advises will might be useful but haven't tried them yet)


回答1:


You can .filter() the markers, .route() them to a different channel or .transform() them to, say, an empty String.

.filter() is probably the easiest in your case, with a "smart" filter that also deletes the file on the end marker.



来源:https://stackoverflow.com/questions/46353317/spring-integration-dsl-dealing-with-filesplitter-start-end-marker-payloads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!