Hello guys,
I just start with Mule, It is very easy the drag and drop part but the rest is quite complicate to me understand...
It is not working as I wish
<flow name="msgflowFlow">
<file:inbound-endpoint path="C:\Users\Rodolfo\Downloads\Mulep" responseTimeout="10000" doc:name="Mulep"/>
<echo-component doc:name="File Transfer to Specific Folder"/>
<choice doc:name="Choice" tracking:enable-default-events="true">
<when expression="# [message.endswith('.txt')]">
<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\B" responseTimeout="10000" doc:name="B"/>
</when>
<when expression="# [message.endswith('.xml')]">
<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\A" responseTimeout="10000" doc:name="A"/>
</when>
<otherwise>
<logger message="# [payload]" level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
</flow>
I want XML files into a paste and TXT files into another
Sorry for newbie xD
@jrberlezi, Firstly, I would recommend to read the documentation to understand what does the component do and what it offers.
Secondly, mule returns `file name` in the inbound properties viz., `originalFileName`, this `inboundProperty` to be used to get hold of the `extension`. try something like this:
# [org.apache.commons.io.FilenameUtils.getExtension(message.inboundProperties.originalFilename)]
which will return the file extension only like `xml/txt/csv`
In essence, to achieve what you want to do is:
<flow name="application_a1Flow2">
<file:inbound-endpoint path="C:\Users\Rodolfo\Downloads\Mulep" responseTimeout="10000" doc:name="File"/>
<set-variable variableName="fileExtension" value="# [org.apache.commons.io.FilenameUtils.getExtension(message.inboundProperties.originalFilename)]" doc:name="Variable"/>
<logger message="# [message.inboundProperties.originalFilename + ' ' + flowVars.fileExtension] and # [flowVars.fileExtension =='xml']" level="INFO" doc:name="Logger"/>
<echo-component doc:name="File Transfer to Specific Folder"/>
<choice doc:name="Choice" tracking:enable-default-events="true">
<when expression="# [flowVars.fileExtension =='txt']">
<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\B" responseTimeout="10000" doc:name="B"/>
</when>
<when expression="# [flowVars.fileExtension =='xml']">
<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\A" responseTimeout="10000" doc:name="A"/>
</when>
<otherwise>
<logger message="# [payload]" level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
</flow>
HTH