如何读取mule esb中的参数

时间:2014-11-04 12:51:50

标签: java mule mule-el mule-component mule-module-jpa

我正在向mule发送一些参数,这些参数正在通过我发送的8081中的http入站进行监听。

http://localhost:8081/hey?age=manoj

但我不知道如何从消息中获取此信息? 我知道我可以从消息和有效负载访问它,但是当我尝试这样做时

#[message payload: ['age']]

我收到错误,有效载荷是一种字符串类型,我非常混淆骡子。 我想要年龄值。

6 个答案:

答案 0 :(得分:6)

如果您使用的是Mule 3.6或更高版本,则表达式已更改。
所以现在,您需要以下表达式来获取值: -

#[message.inboundProperties.'http.query.params'.age]

您可以在此查找参考资料: - https://developer.mulesoft.com/docs/display/current/HTTP+Listener+Connector

答案 1 :(得分:1)

这将作为入境财产进入。您可以使用MEL访问它:

<logger message="#[message.inboundProperties['age']]" level="INFO" doc:name="Logger"/>

请注意,尽管您需要确保在与HTTP入站端点相同的流中使用inboundProperty。

答案 2 :(得分:1)

您可以通过入站属性 http.query.params 检索HTTP查询参数。要获取年龄参数,请使用以下MEL表达式

#[message.inboundProperties.'http.query.params'.get('age')]

答案 3 :(得分:0)

您需要使用Mule HTTP Body to Param Map转换器,将Params转换为Map。

<http:body-to-parameter-map-transformer />      

然后为了访问参数,要使用的MEL表达式为#[payload ['age']]

希望这有帮助。

答案 4 :(得分:0)

在Mule 3.6或3.7中,如果您在mule应用程序中使用了Body to Parameter变换器,则不推荐使用此变换器。如果需要访问入站属性值,可以使用message.inboundProperties。

执行此操作

[message.inboundProperties&#39; http.query.params&#39;]

示例:

    <set-payload value="#[message.inboundProperties.'http.query.params']" doc:name="Set Payload"/>

答案 5 :(得分:0)

如果您想在groovy脚本中使用它,请参阅此

getting inbound properties of ESB Mule message using Groovy

基本上告诉你可以用它作为

message.getInboundProperty('http.query.params')?.yourFantasticParam

message.getInboundProperty('http.query.params')?.age
相关问题