Spring integration DSL example of file polling inbound channel adapter

时间:2015-07-08 15:46:20

标签: spring-integration spring-dsl

Can't find an example anywhere using spring integration DSL only xml. Any pointers appreciated, also need the poller to trigger on file creation and modification

1 个答案:

答案 0 :(得分:2)

这个怎么样:

@Bean
public IntegrationFlow fileReadingFlow() {
    return IntegrationFlows
            .from(s -> s.file(tmpDir.getRoot()).patternFilter("*.sitest"),
                    e -> e.poller(Pollers.fixedDelay(100)))
            .transform(Transformers.fileToString())
            .channel(MessageChannels.queue("fileReadingResultChannel"))
            .get();
}

.from()工厂方法在此接受MessageSources工厂,您使用.file()工厂方法等等。

更多信息在项目测试中:https://github.com/spring-projects/spring-integration-java-dsl/tree/master/src/test/java/org/springframework/integration/dsl/test