问题
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