Mule FTP move file based on filename-wildcard-filter

1.6k Views Asked by At

Current situation:

Mule version 3.5.0

I have an FTP server, where I can connect to using an ftp:inbound-endpoint using a specific path. On that specific path, a lot of files are put (some for us, some for others) so I use a filename-wildcard-filter to filter on specific filename patterns:

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

This works great, but now I also want to create another flow that looks on the same FTP path for files with a different name:

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

This gives me following exception:

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

This means that it is not possible to have two ftp:inbound-endpoints listening at the same host but with a different filename-wildcard-filter...

How can I solve this? Do i specify one flow with one ftp:inbound-endpoint and I split up the incoming files based on the filename or is there a possibility to enable different ftp:inbound-endpoints listening on the same host?

2

There are 2 best solutions below

0
udit khare On

You can try two with two connectors like :

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

And use then as...

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

Resp.

0
KMJ On

Instead of using one single global connector configuration for all FTP components, use a new connector config each time for a different FTP component. This worked out fine for me!

This issue happens due to the same host being used for multiple FTP components. I know we do the same for other components like DB (keeping one global config for all components), and it works out just fine but unusually it doesn't work out for FTP.