2014-08-28 166 views
1
<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服务器上的文件,我不得不配置一个项目像这组十流,他们将访问一个SFTP的diffent路径服务器同时将文件传输到另一台SFTP服务器的不同路径。但是当我运行这个项目时,它返回“SSH_MSG_DISCONNECT:2这个IP的用户太多了”,我该如何解决这个问题,或者有更好的方法来满足这个要求。 有什么建议吗?谢谢传输文件流

回答

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> 

您可能需要修复语法,但逻辑将是那一个。

+0

谢谢你的回答,胡安。 根据你的流程配置, 该流程可以执行sftpA的PATH(A)到sftpB的PATH(A),PATH(B),PATH(C)上的传输文件。那是正确的吗?但我的要求是这样的:将sftpA的PATH(A)上的文件传输到sftpB的PATH(A),将sftpA的PATH(B)上的文件传输到sftpB的PATH(B),将sftpA的PATH(C)上的文件传输到sftpB的PATH C)...在同一时间。任何建议?万分感谢! – user3787636 2014-08-29 02:47:43

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); 
+0

您可以根据需要修改用户名和主机名,并调用明确性。 – senthil 2016-08-23 10:40:11