3. About
The File connector allows your Mule application to exchange files with
a 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.
4. Installation and configuration
Installation:
You can install a connector in Anypoint Studio using the instructions in
Installing a Connector from Anypoint Exchange.
Configuration:
File endpoint configuration consists of two stages:
1. Place the File endpoint within the Mule flow you are developing:
o 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.
o If you place the File building block in the middle or at the end of the flow, it serves as an
outbound endpoint, passing files to the connected file system.
2. Configure the File endpoint by providing values for the fields on the various tabs on
the properties editor.
5. Inbound vs outbound endpoint
Inbound endpoint
Configuration XML Default Representation
<file:inbound-endpoint path="" responseTimeout="10000" doc:name="File"/>
6. Inbound vs outbound endpoint
Outbound endpoint
Configuration XML Default Representation
<file:outbound-endpoint path="" responseTimeout="10000" doc:name="File"/>
7. Reconnection
By default, there is no reconnection strategy implemented for you, but you may
choose to configure reconnection on a set frequency (Standard
Reconnection) or via Custom Reconnection strategy.
11. Continue…
Step 3: Add logger just after it to see the operation in log:
Message:
#['FILE_NAME- '+message.inboundProperties.originalFilename],#['FILE_SIZE- '+((message.inboundProperties.fileSize)/1024)+'KB']]
13. Continue…
Now, we let’s start testing by running the application
Corresponding logger message in console:
Also the files from source directory has been moved to target location. Please
verify the same.
14. Conclusion
So this way we have seen how file connector works as a powerful component
in files movement within local file system.