无法在mule中创建动态文件入站端点 [英] Unable to create dynamic file inbound endpoint in mule

查看:159
本文介绍了无法在mule中创建动态文件入站端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个文件路径作为xml中的mule的输入。使用XPATH表达式,我可以提取路径。我想从该路径读取特定的文件。我试图定义文件入站端点如下。但是似乎没有起作用。

 < 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆