<flow name="test1" doc:name="test1">
<sftp:inbound-endpoint host="${source.server.host}"
port="${source.server.port}" path="${source.server.customer.path}" user="${source.server.user}"
password="${source.server.password}" responseTimeout="10000"
pollingFrequency="${source.server.pollfrequency}" doc:name="source SFTP server" connector-ref="SFTPone"/>
<sftp:outbound-endpoint exchange-pattern="one-way"
outputPattern="#[message.inboundProperties['originalFilename']]"
host="${target.server.host}" port="${target.server.port}" path="${target.server.customer.path}"
user="${target.server.user}" password="${target.server.password}"
responseTimeout="10000" doc:name="Intermediate Host" connector-ref="TARGETSFTPone"/>
</flow>
<flow name="test2" doc:name="test2">
<sftp:inbound-endpoint host="${source.server.host}"
port="${source.server.port}" path="${source.server.wells.path}" user="${source.server.user}"
password="${source.server.password}" responseTimeout="10000"
pollingFrequency="${source.server.pollfrequency}" doc:name="source SFTP server" connector-ref="SFTPtwo"/>
<sftp:outbound-endpoint exchange-pattern="one-way"
outputPattern="#[message.inboundProperties['originalFilename']]"
host="${target.server.host}" port="${target.server.port}" path="${target.server.wells.path}"
user="${target.server.user}" password="${target.server.password}"
responseTimeout="10000" doc:name="Intermediate Host" connector-ref="TARGETSFTPtwo"/>
</flow>
我想从多个路径的sftp服务器传输文件,我在一个项目中配置了10个这样的流程,他们将访问一个SFTP服务器上的不同路径,将文件传输到另一个SFTP服务器的不同路径同一时间。但是当我运行这个项目时,它返回了&#34; SSH_MSG_DISCONNECT:2这个IP的用户太多了#34; ,我该如何解决此问题,或者有更好的方法来满足此要求。 有什么建议吗?感谢
答案 0 :(得分:0)
您可以使用foreach +动态端点的组合来执行此操作,但缺点是您需要在入站端点之后禁用SFTP连接器中的流(或使用对象到流转换器),即:它看起来像
<sftp:inbound endpoint>
<object-to-byte-array />
<set-variable variableName="fileContents" value="#[payload]" />
<foreach value="#[expressionToTheListOfSites]">
<set-variable variableName="site" value="#[payload]" />
<set-payload value="#[fileContents]" />
<sftp:outbound-endpoint address="sftp://#[site]" />
</foreach>
您可能需要修复语法,但逻辑将是那个。
答案 1 :(得分:0)
Inbound:
EndpointBuilder endpointBuilder = eventContext
.getMuleContext()
.getEndpointFactory()
.getEndpointBuilder(
"sftp"+"://" + userName+ ":"
+ password+ "@"
+ host+ ":"+port
+ path+"?connector=SFTPIN");
InboundEndpoint inboundEndPoint = endpointBuilder.buildInboundEndpoint();
endpointBuilder.addMessageProcessor(new MessageFilter(new WildcardFilter("sample*")));
endpointBuilder.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
MuleMessage message= inboundEndPoint.request(1000000L);
outbound:
//To send file to destination
EndpointBuilder outboundEndpointBuilder = eventContext
.getMuleContext()
.getEndpointFactory()
.getEndpointBuilder(
"sftp"+"://" + userName+ ":"
+ password+ "@"
+ host+ ":"+port
+ path+"?connector=SFTPOUT");
OutboundEndpoint outboundPoint=outboundEndpointBuilder.buildOutboundEndpoint();
SftpConnector sftpConnector=(SftpConnector) outboundPoint.getConnector();
sftpConnector.setOutputPattern("sample1.txt");
eventContext.getMuleContext().getClient().process(outboundPoint, msg);