[英]Nio locker usage in spring integration java dsl for file polling
[英]how to do Ftp polling with Spring integration DSL
我正在尝试为下面描述的流程创建动态ftp入站适配器
<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel" session-factory="ftpClientFactory"
filename-pattern="*.txt" auto-create-local-directory="true"
delete-remote-files="false" remote-directory="${remotedir}"
local-directory="/mock/test" auto-startup="true">
<int:poller fixed-rate="1000">
<int:transactional synchronization-factory="syncFactory" />
</int:poller>
</int-ftp:inbound-channel-adapter>
为此,我使用SI动态注册创建了以下SI Java dsl流,如下所示:
public void createSubFlows(FtpConfig config) {
DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
Connection connection = config.getConnection();
Feed feed = config.getFeed();
sf.setHost(connection.getHost());
sf.setPort(connection.getPort());
sf.setUsername(connection.getUsername());
sf.setPassword(connection.getPassword());
IntegrationFlow flow = IntegrationFlows
.from(Ftp.inboundAdapter(csf).preserveTimestamp(true)
.remoteDirectory(feed.getRemoteDirectory())
.regexFilter(".*\\.txt$")
.localDirectory(new File(feed.getLocalDirectory())),
e -> e.id("ftpInboundAdapter" + connection.getId()
+ feed.getId())//
).handle(m -> System.out.println(m.getPayload())).get();
this.flowContext.registration(flow)
.id("ftp.flow" + connection.getId() + feed.getId()).autoStartup(true)
.register();
}
相同的方法很好用,但是我还想配置一个动态轮询器,类似于上面的xml。 是否可以对SI Java DSL进行同样的操作
更新
尽管不确定为什么它没有出现在内容帮助中,但看起来似乎可行
e -> e.poller(Pollers.fixedRate(100).maxMessagesPerPoll(1))
你肯定e
的.from()
没有.poller()`:
from(Ftp.inboundAdapter(csf)
.preserveTimestamp(true)
.remoteDirectory(feed.getRemoteDirectory())
.regexFilter(".*\\.txt$")
.localDirectory(new File(feed.getLocalDirectory())),
e -> e.id("ftpInboundAdapter" + connection.getId()
+ feed.getId()
.poller())
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.