File Connector
The File connector allows your Mule application to exchange files within the local file system. You can implement the File connector as an inbound endpoint (such as, a message source), or as an outbound endpoint. This endpoint implements a one-way exchange pattern only.
Reference: File Transport Reference
The File connector only supports working with files on the same physical system as the running application. It doesn’t transfer files remotely over network connections. The only exception is when the operating system maps remote connections to local directories transparently. In this case, the operating system transfers file remotely in the background. For the connector, the files are stored locally and it doesn’t know about which networking protocols are being used to perform the sharing. This dependency on the file system and the operating system imply caveats when using the file transport in a HA environment with a remotely shared folder. In the case of Windows shared folders, there is a latency in the update of file metadata so that a node in a cluster may eventually take an already deleted file as still existing. This may result in reprocessing of a file if the autodelete flag is set. These system properties fix this problem:
|
Install this Connector
-
In Anypoint Studio, click the Exchange icon in the Studio taskbar.
-
Click Login in Anypoint Exchange.
-
Search for the connector and click Install.
-
Follow the prompts to install the connector.
When Studio has an update, a message displays in the lower right corner, which you can click to install the update.
Configuration
File endpoint configuration consists of two stages:
-
Place the File endpoint within the Mule flow you are developing:
-
If you place the File endpoint at the beginning of the flow, it acts as an inbound endpoint (such as, message source), triggering the flow whenever it receives an incoming file. (You can also use the Composite Source scope to wrap the File endpoint along with other, similar endpoints (such as FTP, SFTP, or UDP) so that your flow can receive files through multiple transport channels).
-
If you place the File processor in the middle or at the end of the flow, it serves as an outbound endpoint, passing files to the connected file system.
-
-
Configure the File endpoint by providing values for the fields on the various tabs on the properties editor.
Open the File properties editor by double-clicking the File icon on the Message Flow canvas. Configure the tabs as shown.
Inbound Endpoint
The file connector is used as an inbound endpoint when it is a message source for the flow, that is, on the "source" end, where you see the connector icon at left. |
<file:inbound-endpoint path="" responseTimeout="10000" doc:name="File"/>
The File connector as inbound endpoint does not process empty (0 bytes) files. |
Outbound Endpoint
<file:outbound-endpoint path="" responseTimeout="10000" doc:name="File"/>
Property | Description |
---|---|
Display Name |
Defaults to the generic endpoint name. Change the display name, which must be alpha-numeric, to reflect the endpoint’s specific role, such as |
Path |
The target directory on the connected file system. If File is implemented as an inbound endpoint, this would be the location within the connected file system of the file being transferred into the flow. For an outbound File endpoint, this would be the directory on the connected file system to which the file currently in the flow is written. |
Move to Pattern |
(Applies to inbound File endpoints only) . The pattern to be used when moving a file according to the Move to Directory property. It can use the patterns specified by the filename parser configured (often through a Connector template) for this particular File endpoint. |
Move to Directory |
(Applies to inbound File endpoints only.) Typically, the file being received is simply read by the inbound endpoint and dispatched to the next processor in the flow. To save a copy on the Mule host machine, specify a path in this field. |
Connector Configuration |
Use the dropdown list to select a previously created connector configuration for this endpoint. If you have not created a connector configuration for this type of endpoint, you can do so from this window by clicking Add . Click Edit to modify a previously created global element. |
Polling Frequency |
(Applies to inbound File endpoints only.) Specify how often the endpoint should check for incoming messages. The default value is 1000 ms. |
File Age |
(Applies to inbound File endpoints only.) Sets a minimum period in milliseconds that a file must wait before it is processed. This helps ensure that long files are received in their entirety before processing starts. However, Mule and the connected file system must be on synchronized time for this feature to work properly. |
File Name Regex Filter |
(Applies to inbound File endpoints only.) Configure a filter to restrict the files being processed. |
File Name / Pattern |
(Applies to outbound File endpoint only). Specify a filename or pattern for naming files that are sent from the File endpoint to the connected file system. If not set, the File endpoint uses the same file-naming pattern used for incoming files. |
When using a File inbound endpoint to poll a directory, an exception is thrown if the directory to be polled doesn’t exist. |
Advanced Tab
Property | Description |
---|---|
Address |
Enter the address for this endpoint, such as |
Response Timeout |
Specify how long (in ms) the endpoint waits for a response from the connected file system. |
Encoding |
Choose from a drop-down list the character set used for message data. (such as UTF-8). |
Disable Transport Transformer |
Check this box if you do not want to use the endpoint’s default response transport. |
MIME Type |
Select from the dropdown list one of the formats this endpoint supports. |
Connector Endpoint |
Use the dropdown list to select a previously configured global endpoint reference. If you have not created a global element for this type of endpoint, you can do so from this window by clicking Add. Click Edit to modify a previously created global element. |
Comparator |
(Applies to inbound File endpoints only) . Specify the comparator used to sort incoming files, as in |
Reverse Order |
(Applies to inbound File endpoints only) . Check this box to reverse the normal comparator sort order. |
Enable default events tracking |
Enable default business event tracking for this endpoint. |
Transformers Tab
Property | Description |
---|---|
Transformers References: Request |
Enter a list of synchronous transformers that are applied to the request before it is sent to the transport. |
Global Transformers |
Reference the global transformers you desire. Enter a list of synchronous transformers that are applied to the response before it is returned from the transport and order them for your needs. |
See Also
-
See the File Transport Reference for details on setting the properties for a File endpoint using an XML editor.
-
Review DataWeave FlatFile Schemas doc for information on how to define the file format.