[英]How to use multiple sftp outbound-gateway
I'm new in Spring Integration and I'm working with two process: 我是Spring Integration的新手,正在使用两个过程:
1.- Read files from sftp, save information. 1.-从sftp读取文件,保存信息。 I use method "mget".
我使用方法“ mget”。
2.- After of save information, rename files processed in sftp server with method "mput". 2.-保存信息后,使用方法“ mput”重命名在sftp服务器中处理的文件。
this is my configuration: 这是我的配置:
<bean id="filePrinter" class="com.maven.integration.FilePrinter" />
<int:channel id="outboundChannel"></int:channel>
<int:channel id="aggregateResultsChannel"/>
<int:channel id="toGet"></int:channel>
<int:gateway id="simpleGateway" service-interface="com.maven.integration.FileGateway"
default-request-channel="ftpChannel" />
<int-sftp:outbound-gateway
session-factory="sftpClientFactory"
request-channel="ftpChannel"
command="mget"
command-options="-R -P"
expression="payload"
filename-regex="(new|.*.csv)"
mode="IGNORE"
local-directory-expression="@targetDir.get() + #remoteDirectory"
reply-channel="outboundChannel"
>
<int-sftp:request-handler-advice-chain>
<int:retry-advice />
</int-sftp:request-handler-advice-chain>
</int-sftp:outbound-gateway>
<int:splitter input-channel="outboundChannel" output-channel="toGet"/>
<bean id="targetDir" class="java.util.concurrent.atomic.AtomicReference">
<constructor-arg value="${target}"/>
</bean>
<int:service-activator ref="filePrinter" method="print"
input-channel="toGet"/>
<int-sftp:outbound-gateway
session-factory="sftpClientFactory"
request-channel="toGet"
command="mput"
command-options="-R"
local-directory="src/test/"
expression="payload"
filename-regex="(new|.*.csv)"
mode="IGNORE"
remote-filename-generator-expression="payload.getName() + '.ack'"
remote-directory-expression="#remoteDirectory"
reply-channel="aggregateResultsChannel"
>
<int-sftp:request-handler-advice-chain>
<int:retry-advice />
</int-sftp:request-handler-advice-chain>
</int-sftp:outbound-gateway>
<int:aggregator input-channel="aggregateResultsChannel"/>
currently only the first outbound-gateway with mget command is executed, but the second outbound-gateway is not executed, how could the second process run? 当前只有执行带mget命令的第一个出站网关,而没有执行第二个出站网关,第二个进程如何运行?
Because your toGet
is a simple DirectChannel
with the "only one per message subscriber" logic. 因为您的
toGet
是一个简单的DirectChannel
具有“每个消息订阅者一个”逻辑。 At the same time your mput
gateway uses that as its request-channel="toGet"
sharing this channel with the <int:service-activator>
. 同时,您的
mput
网关将其用作其request-channel="toGet"
与<int:service-activator>
共享此信道。 And since this is earlier in the config, it is a first subscriber in the
toGet and therefore only this one process the message sent to the
toGet` by the splitter. 而且由于这
is earlier in the config, it is a first subscriber in the
toGet中is earlier in the config, it is a first subscriber in the
and therefore only this one process the message sent to the
由分离器and therefore only this one process the message sent to the
toGet and therefore only this one process the message sent to the
。
I think what you need to do (if the story is still about mput
) is exactly opposite with what you have in mget
. 我认为您需要做的(如果故事仍然是关于
mput
)与您在mget
所做的完全相反。 So, you should do that logic alongside with the splitting, not after. 因此,您应该将逻辑与拆分同时进行,而不是事后进行。 Therefore you should send
MGET
result to the splitter and to the MPUT
in parallel. 因此,您应该将
MGET
结果并行发送到分离器和MPUT
。 For this purpose I suggest you to change your outboundChannel
to the <publish-subscribe-channel>
and use this outboundChannel
in the mput
gateway for its request-channel
. 为此,我建议您将
outboundChannel
更改为<publish-subscribe-channel>
并在mput
网关中将此outboundChannel
用作其request-channel
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.