Example usage for org.springframework.integration.file.dsl Files splitter

List of usage examples for org.springframework.integration.file.dsl Files splitter

Introduction

In this page you can find the example usage for org.springframework.integration.file.dsl Files splitter.

Prototype

public static FileSplitterSpec splitter(boolean iterator, boolean markers) 

Source Link

Document

The FileSplitterSpec builder factory method with iterator and markers flags specified.

Usage

From source file:org.springframework.integration.samples.filesplit.Application.java

/**
 * Poll for files, add an error channel, split into lines route the start/end markers
 * to {@link #markers()} and the lines to {@link #lines}.
 *
 * @return the flow./*w  ww. j a v  a  2  s  . c  o  m*/
 */
@Bean
public IntegrationFlow fromFile() {
    return IntegrationFlows
            .from(Files.inboundAdapter(new File("/tmp/in")).preventDuplicates(false).patternFilter("*.txt"),
                    e -> e.poller(Pollers.fixedDelay(5000).errorChannel("tfrErrors.input"))
                            .id("fileInboundChannelAdapter"))
            .handle(Files.splitter(true, true))
            .<Object, Class<?>>route(Object::getClass,
                    m -> m.channelMapping(FileSplitter.FileMarker.class, "markers.input")
                            .channelMapping(String.class, "lines.input"))
            .get();
}