Spring integration 如何使用jdbc出站通道适配器过滤Spring集成流?

Spring integration 如何使用jdbc出站通道适配器过滤Spring集成流?,spring-integration,spring-jdbc,Spring Integration,Spring Jdbc,我有一个要求,我必须通过FTP从远程服务器读取XML文件,并将其转储到本地目录中。之后,我必须使用传入负载中的值对数据库发起SQL查询,然后根据查询结果决定是否继续该流 <int-ftp:inbound-channel-adapter id="ftpInbound1" channel="inboundFTPFileChannel" session-factory="ftpSessionFactory" local-filter="compositeFilte

我有一个要求,我必须通过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集成消息相同。请给我一些建议


我能做的就是编写一个
,它引用返回true或false的bean。但是我只是想避免编写这个Java代码

将原始有效负载保存在标头中,稍后再恢复

<int:header-enricher ...>
    <int:header name="savedPayload" expression="payload" />
</int:header-enricher>

<int:jdbc-outbound-gateway... />

<int:filter ... expression="payload > 0" />

<int:transformer ... expression="headers['savedPayload']" />

...

...
注意,您需要使用网关,而不是通道适配器(JDBC)


如果您愿意,您可以将所有这些放入
中。

欢迎!您能告诉我们您在这个阶段有什么错误或问题吗?