使用Java DSL从文件轮询 – 添加Files.inboundAdapter时编译错误
我正在使用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
第二个问题的答案。