File Connector in Mule
File connector is used to read,write,delete & transfer of files.
flow of file connector :
Above example is to read a json file stored in input folder of src/main/resources
input.json :
{
"id" : 1,
"name" : "Himanshu",
"city" : "Pune"
}
file connector configuration :
General settings :
Connector Configuration :
Logger Output :
XML project code :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<file:connector name="File" outputPattern="input.json" readFromDirectory="src/main/resources/input" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="test_fileFlow">
<file:inbound-endpoint path="src/main/resources/input" connector-ref="File" pollingFrequency="10000" responseTimeout="10000" doc:name="File"/>
<object-to-string-transformer doc:name="Object to String"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
No comments:
Post a Comment