Example usage for org.springframework.integration.dsl SourcePollingChannelAdapterSpec poller

List of usage examples for org.springframework.integration.dsl SourcePollingChannelAdapterSpec poller

Introduction

In this page you can find the example usage for org.springframework.integration.dsl SourcePollingChannelAdapterSpec poller.

Prototype

public SourcePollingChannelAdapterSpec poller(PollerMetadata pollerMetadata) 

Source Link

Usage

From source file:org.springframework.cloud.stream.app.ftp.source.FtpSourceConfiguration.java

@Bean
public IntegrationFlow ftpInboundFlow(SessionFactory<FTPFile> ftpSessionFactory, FtpSourceProperties properties,
        FileConsumerProperties fileConsumerProperties) {
    FtpInboundChannelAdapterSpec messageSourceBuilder = Ftp.inboundAdapter(ftpSessionFactory)
            .preserveTimestamp(properties.isPreserveTimestamp()).remoteDirectory(properties.getRemoteDir())
            .remoteFileSeparator(properties.getRemoteFileSeparator()).localDirectory(properties.getLocalDir())
            .autoCreateLocalDirectory(properties.isAutoCreateLocalDir())
            .temporaryFileSuffix(properties.getTmpFileSuffix())
            .deleteRemoteFiles(properties.isDeleteRemoteFiles());

    if (StringUtils.hasText(properties.getFilenamePattern())) {
        messageSourceBuilder.filter(new FtpSimplePatternFileListFilter(properties.getFilenamePattern()));
    } else if (properties.getFilenameRegex() != null) {
        messageSourceBuilder.filter(new FtpRegexPatternFileListFilter(properties.getFilenameRegex()));
    }//from   w  w  w.  j  a  v a2 s.  c o m

    IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(messageSourceBuilder,
            new Consumer<SourcePollingChannelAdapterSpec>() {

                @Override
                public void accept(SourcePollingChannelAdapterSpec sourcePollingChannelAdapterSpec) {
                    sourcePollingChannelAdapterSpec.poller(FtpSourceConfiguration.this.defaultPoller);
                }

            });

    return FileUtils.enhanceFlowForReadingMode(flowBuilder, fileConsumerProperties)
            .channel(this.source.output()).get();
}