【问题标题】:Mule FTP move file based on filename-wildcard-filterMule FTP 基于文件名通配符过滤器移动文件
【发布时间】:2015-07-29 15:45:11
【问题描述】:

目前情况:

骡子版本 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 在同一主机上侦听?

【问题讨论】:

  • 我认为你不能同时拥有两个端点。您可以使用一个正则表达式过滤器来获取这两种文件,然后您可以使用选择元素再次路由(或者更好的是,设置一个“路径”变量以便稍后在出站中使用)。 HTH。
  • 使用一个 ftp 入站端点(接收所有文件),然后使用基于通配符的过滤器并将其路由到 @afelisatti 建议的不同目的地

标签: ftp mule flow mule-component


【解决方案1】:

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

<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" .....

回复

【讨论】:

    【解决方案2】:

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

    此问题是由于多个 FTP 组件使用同一主机所致。我知道我们对 DB 等其他组件也这样做(为所有组件保留一个全局配置),它运行得很好,但不同寻常的是它不适用于 FTP。

    【讨论】:

      猜你喜欢
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 1970-01-01
      • 2017-05-09
      • 2011-06-28
      • 1970-01-01
      相关资源
      最近更新 更多