Skip to main content

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="#&nbsp;[message.endswith('.txt')]">

<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\B" responseTimeout="10000" doc:name="B"/>

</when>

<when expression="#&nbsp;[message.endswith('.xml')]">

<file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\A" responseTimeout="10000" doc:name="A"/>

</when>

<otherwise>

<logger message="#&nbsp;[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

1 answer
  1. Nov 3, 2016, 7:32 PM

    @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="#&nbsp;[org.apache.commons.io.FilenameUtils.getExtension(message.inboundProperties.originalFilename)]" doc:name="Variable"/>

    <logger message="#&nbsp;[message.inboundProperties.originalFilename + ' ' + flowVars.fileExtension] and #&nbsp;[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="#&nbsp;[flowVars.fileExtension =='txt']">

    <file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\B" responseTimeout="10000" doc:name="B"/>

    </when>

    <when expression="#&nbsp;[flowVars.fileExtension =='xml']">

    <file:outbound-endpoint path="C:\Users\Rodolfo\Downloads\MuleTests\A" responseTimeout="10000" doc:name="A"/>

    </when>

    <otherwise>

    <logger message="#&nbsp;[payload]" level="INFO" doc:name="Logger"/>

    </otherwise>

    </choice>

    </flow>

     

    HTH

0/9000