Mule FTP基于filename-wildcard-filter移动文件

时间:2015-07-29 15:45:12

标签: ftp mule flow mule-component

现状:

Mule版本3.5.0

我有一个FTP服务器,我可以使用特定路径使用ftp:inbound-endpoint连接到该服务器。 在那个特定的路径上,放了很多文件(一些用于我们,一些用于其他文件)所以我使用文件名通配符过滤器来过滤特定的文件名模式:

<flow name="flowA">
    <ftp:inbound-endpoint host="${ftp.host}" port="${ftp.port}" user="${ftp.username}" password="${ftp.password}" path="${ftp.root.in}">
        <file:filename-wildcard-filter pattern="${environment}*TYPE_A*.xml.gz" caseSensitive="false"/>
        <gzip-uncompress-transformer/>
    </ftp:inbound-endpoint>
    <file:outbound-endpoint path="${home.dir}/typeA/in" responseTimeout="10000" outputPattern="#[message.inboundProperties.originalFilename]"/>
</flow>

这很好用,但是现在我还想创建另一个流,它在同一个FTP路径上查找具有不同名称的文件:

<flow name="flowB">
    <ftp:inbound-endpoint host="${ftp.host}" port="${ftp.port}" user="${ftp.username}" password="${ftp.password}" path="${ftp.root.in}">
        <file:filename-wildcard-filter pattern="${environment}*TYPE_B*.xml.gz" caseSensitive="false"/>
        <gzip-uncompress-transformer/>
    </ftp:inbound-endpoint>
    <file:outbound-endpoint path="${home.dir}/typeB/in" responseTimeout="10000" outputPattern="#[message.inboundProperties.originalFilename]"/>
</flow>

这给了我以下例外:

Caused by: org.mule.api.transport.ConnectorException: There is already a listener registered on this connector on endpointUri: XXX

这意味着不可能有两个ftp:inbound-endpoints在同一主机上侦听但使用不同的文件名 - 通配符过滤器...

我该如何解决这个问题?我是否使用一个ftp:inbound-endpoint指定一个流,我根据文件名分割传入的文件,或者是否有可能在同一主机上启用不同的ftp:inbound-endpoints?

2 个答案:

答案 0 :(得分:0)

您可以尝试使用两个连接器,例如:

<sftp:connector name="SFTP" validateConnections="false" doc:name="SFTP" autoDelete="false" />
<sftp:connector name="SFTP1" validateConnections="false" doc:name="SFTP" autoDelete="false"/>

然后将其用作...

<sftp:inbound-endpoint connector-ref="SFTP" ......
<sftp:inbound-endpoint connector-ref="SFTP1" .....

响应

答案 1 :(得分:0)

不要为所有FTP组件使用一个单一的全局连接器配置,而是每次对一个不同的FTP组件使用一个新的连接器配置。这对我来说很好!

发生此问题的原因是同一主机用于多个FTP组件。我知道我们对其他组件(如DB)执行相同的操作(为所有组件保留一个全局配置),但效果很好,但对于FTP来说却不正常。