Question

I get a file path as an input to mule inside xml. Using XPATH expression, I am able to extract the path. I want to read a particular file from that path. I tried to define file inbound endpoint as below. But it doesn't seem to be working.

    <flow name="flow1">
     ....
     ....
    <set-session-variable variableName="filePath" value="#[xpath://filePath]" />
    <flow-ref name="fileFlow"/>
    </flow>

    <flow name="fileFlow">
    <file:inbound-endpoint path="#[header:SESSION:filePath]" />
    </flow>

My understanding here is that no code can be placed before an inbound-endpoint. Hence I defined it in another flow. Please suggest if there is a way to read the file from a specified path.

Was it helpful?

Solution

Unfortunately, you cannot programmatically call an inbound-endpoint like that.

However the same functionality can be achieved using the Mule requester module:

Example:

  <flow name="RequestFile" doc:name="RequestFile">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="requestfile" doc:name="HTTP"/>
        <mulerequester:request config-ref="Mule_Requester" resource="file:///s/tmp/demorequester/read/#[message.inboundProperties['filename']]" returnClass="java.lang.String" doc:name="Request a file"/>
    </flow>

Instructions here: https://github.com/mulesoft/mule-module-requester and https://blogs.mulesoft.com/dev/mule-dev/introducing-the-mule-requester-module/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top