无法在mule中创建动态文件入站端点 [英] Unable to create dynamic file inbound endpoint in mule
问题描述
< flow name =flow1>
....
....
< set-session-variable variableName =filePathvalue =#[xpath:// filePath]/>
< flow-ref name =fileFlow/>
< / flow>
< flow name =fileFlow>
< file:inbound-endpoint path =#[header:SESSION:filePath]/>
< / flow>
我的理解是在入站端点之前没有代码可以放置。因此我在另一个流程中定义了它。请建议是否有方法从指定的路径读取文件。
不幸的是,您无法以编程方式调用这样的入站端点。
但是,使用Mule请求者模块可以实现相同的功能:
示例:
< flow name =RequestFiledoc:name =RequestFile>
< http:inbound-endpoint exchange-pattern =request-responsehost =localhostport =8081path =requestfiledoc:name =HTTP/>
< mulerequester:request config-ref =Mule_Requesterresource =file:/// s / tmp / demorequester / read /#[message.inboundProperties ['filename']]returnClass =java.lang .Stringdoc:name =请求文件/>
< / flow>
说明: https://github.com/mulesoft/mule-module-requester 和 https://blogs.mulesoft.com/dev/mule-dev/introducing-the-mule-requester-module/
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.
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/
这篇关于无法在mule中创建动态文件入站端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!