2

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)

hummingV
  • 1,014
  • 1
  • 11
  • 25

1 Answers1

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.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • See https://stackoverflow.com/questions/46350357/spring-integration-dsl-configure-handler-that-handles-only-when-the-argument-ma for more context – Artem Bilan Sep 22 '17 at 01:20