Unable to create dynamic file inbound endpoint in mule

不羁的心 提交于 2019-12-01 23:35:39

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/21636573/unable-to-create-dynamic-file-inbound-endpoint-in-mule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!