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

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

Introduction

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

Prototype

public static FileInboundChannelAdapterSpec inboundAdapter(File directory) 

Source Link

Document

Create a FileInboundChannelAdapterSpec builder for the FileReadingMessageSource .

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./*from  w  w  w.  j a va 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();
}