Polling from file using Java DSL - compile error when adding Files.inboundAdapter

后端 未结 1 1306
刺人心
刺人心 2021-01-26 04:05

I am using Spring Integration Java DSL v. 1.2.2 and following some examples I try to write a code to poll a folder

    return IntegrationFlows
            .from(         


        
1条回答
  •  [愿得一人]
    2021-01-26 04:28

    Not clear what's going on in your IDE, but we have this sample in test-cases:

    @Bean
    public IntegrationFlow fileToFile() {
        return IntegrationFlows.from(Files.inboundAdapter(new File("/tmp/in"))
                        .autoCreateDirectory(true)
                        .patternFilter("*.txt"),
                e -> e.poller(Pollers.fixedDelay(5000)))
                .transform(Transformers.fileToString())
                .transform("payload.replaceAll('\r\n', '\n')")
                .handle(Files.outboundAdapter("'/tmp/out'")
                        .autoCreateDirectory(true))
                .get();
    }
    

    The fixedDelay() is an answer to your second question about fixed-interval.

    https://github.com/spring-projects/spring-integration-java-dsl/blob/master/src/test/java/org/springframework/integration/dsl/samples/file2file1/FileChangeLineSeparator.java

    0 讨论(0)
提交回复
热议问题