Mule 无法从 SFTP 位置下载文件

Mule faile to download file from SFTP location

我正在尝试连接到 SFTP 位置并使用 Mule SFTP 连接器下载 .zip 文件。它看起来非常简单的配置,但我不确定我的配置中缺少什么。我无法弄清楚为什么它对我不起作用。有人可以看看它并建议我应该改变什么才能工作吗?

在下面的流程配置中,我从一个 HTTP 端点 (http://localhost:8181/invoice) 开始,然后调用“ftpconnectivityFlow1”并检查 "ftp" 变量的值,并根据它的值前往我的 FTP 位置或 SFTP 位置。当我将变量 "ftp" 设置为 true 时,它​​按预期工作,因为我可以看到来自 FTP 位置的文件已下载到我的输出文件夹中,并按预期从 FTP 位置删除。当我将它设置为 false 时,它​​没有给出任何错误,但 SFTP 位置的文件仍然存在,这意味着它无法读取文件(我猜)并且它没有下载到我的输出文件夹。因此,对于一些调试,我添加了一个自定义转换器,以便我可以检查有效负载。在我的自定义转换器中,我注意到当它连接到 FTP 位置时它有一些二进制数据(所有数字),我猜这是我的 .zip 文件,但是当变量 "ftp" 设置为 false 时,这意味着它正在尝试连接到 SFTP 位置,在这种情况下,有效负载包含“/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>
<ftp:inbound-endpoint host="host" port="22" ... doc:name="FTP"/>
...
 <sftp:inbound-endpoint ... port="21" user="user"/>

你可能把这些端口号弄反了。 FTP 通常在端口 21 上运行,SFTP (SSH) 通常使用端口 22。