我正在使用 Spring Integration Java DSL v. 1.2.2 并按照一些示例尝试编写代码来轮询文件夹
return IntegrationFlows
.from(Files.inboundAdapter(new File("/tmp/foo")))
.handle((p, h) -> fileProcessor.process(p))
.get();
此代码无法编译,因为
"Cannot resolve method 'from(org.springframework.integration.dsl.
file.FileInboundChannelAdapterSpec)'"
如何解决此问题以及如何添加固定间隔轮询?
最佳答案
不清楚您的 IDE 中发生了什么,但我们在测试用例中有此示例:
@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
的第二个问题的答案。
关于java - 使用 Java DSL 从文件轮询 - 添加 Files.inboundAdapter 时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44524793/