【发布时间】:2015-10-11 04:16:11
【问题描述】:
我有一个要求,我必须通过 FTP 从远程服务器读取 XML 文件并将它们转储到本地目录中。之后,我必须使用传入有效负载中的值对数据库进行 SQL 查询,然后 - 基于查询的结果 - 决定是否要继续流程。
<int-ftp:inbound-channel-adapter id="ftpInbound1"
channel="inboundFTPFileChannel" session-factory="ftpSessionFactory"
local-filter="compositeFilter" filename-pattern="*.xml"
preserve-timestamp="true" charset="UTF-8" remote-directory="${remote.request.cdr.circle.dir}"
remote-file-separator="/" local-directory="${local.request.dir}">
<int:poller fixed-rate="${ftp.file.poller.interval}"
time-unit="SECONDS" max-messages-per-poll="-1" />
</int-ftp:inbound-channel-adapter>
<int:filter input-channel="inboundFTPFileChannel"
output-channel="jdbcChannel" discard-channel="discardChannel"
expression="payload.isFile()" />
<int-jdbc:outbound-channel-adapter
channel="jdbcChannel" query="SELECT COUNT(1) FROM some_table WHERE some_col = some_value"
data-source="myDataSource" />
在这个阶段,如果查询返回非零输出,我想继续流程。否则,此消息的流程应该结束。此外,如果流程应该继续,则到下一个通道的输出应该是来自“jdbcChannel”的相同 Spring 集成消息。请指教。
我绝对可以写一个<int:filter>,它引用一个返回真或假的bean。但我只是想避免编写这段 Java 代码!
【问题讨论】:
-
欢迎您!您能否告诉我们您在这个阶段遇到了什么错误或问题?
标签: spring-integration spring-jdbc