2014-08-28 172 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