2017-10-13 88 views
0

我想連接到SFTP位置並使用Mule SFTP連接器下載.zip文件。它看起來非常直接,但我不確定我的配置中缺少什麼。我無法弄清楚爲什麼它不適合我。有人可以看看它,並建議我應該改變什麼工作?Mule無法從SFTP位置下載文件

在下面的流程配置中,我從一個HTTP終點(http://localhost:8181/invoice)開始,然後調用「ftpconnectivityFlow1」並檢查「ftp」變量的值,並根據它的值將它轉到我的FTP位置或SFTP位置。當我將變量「ftp」設置爲true時,它按預期工作,因爲我可以看到來自FTP位置的文件已下載到我的輸出文件夾中,並按預期從FTP位置刪除。當我將它設置爲false時,它不會給出任何錯誤,但是SFTP位置處的文件仍然存在,這意味着它不能讀取文件(我猜測),並且它不會下載到我的輸出文件夾中。所以對於一些調試,我添加了一個自定義轉換器,以便我可以檢查有效載荷。在我的自定義轉換器中,我注意到當它連接到FTP位置時,它有一些二進制數據(所有數字),我猜它是我的.zip文件,但當變量「ftp」設置爲false時,表示它試圖連接在這種情況下,有效載荷包含「/ invoice」,這是我的http相對路徑。所以我的輸出文件夾包含一個名稱爲「null」的文件,它包含的所有文件是「/ invoice」

任何幫助,非常感謝。

<flow name="ftpconnectivityFlow1"> 

    <logger message="ftp:#[message.outboundProperties['ftp']]" doc:name="Logger" level="INFO"/> 
    <choice doc:name="Choice"> 
     <when expression="#[message.outboundProperties['ftp']==true]"> 
      <flow-ref name="FTPConnection" doc:name="FTPFileDownloadConnection"/> 
     </when> 
     <otherwise> 
      <flow-ref name="SFTPConnection" doc:name="SFTPFileDownloadConnection"/> 
     </otherwise> 
    </choice> 
</flow> 

<flow name="FTPConnection"> 
    <ftp:inbound-endpoint host="host" port="22" path="abc" user="user" password="password" responseTimeout="10000" doc:name="FTP"/> 
    <custom-transformer class="abc.transformer.CustomeFileTransformer" /> 
    <logger message="connected to FTP" level="INFO" doc:name="Logger"/> 
    <file:outbound-endpoint path="output" outputPattern="#[message.inboundProperties['originalFilename']]" responseTimeout="10000" doc:name="File"/> 
</flow> 

<flow name="SFTPConnection"> 
    <sftp:inbound-endpoint  connector-ref="sftp-default" doc:name="SFTP" responseTimeout="10000" host="host" password="password" path="/Inbound" port="21" user="user"/> 
    <custom-transformer class="abc.transformer.CustomeFileTransformer" /> 

    <logger level="INFO" doc:name="Logger"/> 
    <file:outbound-endpoint path="output" outputPattern="#[message.inboundProperties['originalFilename']]" responseTimeout="10000" doc:name="File"/> 

</flow> 

回答

0
<ftp:inbound-endpoint host="host" port="22" ... doc:name="FTP"/> 
... 
<sftp:inbound-endpoint ... port="21" user="user"/> 

你可能有這些端口號倒退。 FTP通常在端口21上運行,SFTP(SSH)通常使用端口22.

+0

感謝您的輸入,仔細檢查後發現問題是密碼中的端口和特殊字符的組合,我仍然不確定爲什麼我不是獲取錯誤消息。但最後我的問題解決了。 – Rai