使用 Java DSL 从文件中轮询 - 添加 Files.inboundAdapter 时编译错误 [英] Polling from file using Java DSL - compile error when adding Files.inboundAdapter
本文介绍了使用 Java DSL 从文件中轮询 - 添加 Files.inboundAdapter 时编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Spring Integration Java DSL v. 1.2.2 并按照一些示例尝试编写代码来轮询文件夹
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(Files.inboundAdapter(new File("/tmp/foo")))
.handle((p, h) -> fileProcessor.process(p))
.get();
这段代码无法编译,因为
This code can not be compiled because
"Cannot resolve method 'from(org.springframework.integration.dsl.
file.FileInboundChannelAdapterSpec)'"
如何解决这个问题以及如何添加固定间隔轮询?
How this can be fixed and how fixed-interval polling can be added?
推荐答案
不清楚您的 IDE 中发生了什么,但我们在测试用例中有此示例:
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();
}
fixedDelay()
是您关于 fixed-interval
的第二个问题的答案.
The fixedDelay()
is an answer to your second question about fixed-interval
.
这篇关于使用 Java DSL 从文件中轮询 - 添加 Files.inboundAdapter 时编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文