【问题标题】:How to read parameter in mule esb如何读取 mule esb 中的参数
【发布时间】:2014-12-31 08:54:25
【问题描述】:

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

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

但我不知道我怎么能把它当作来自消息? 我知道我可以从消息和有效负载中访问它,但是当我尝试这样做时

#[message payload: ['age']]

我收到错误消息,payload 是 String 类型,我对 mule 感到非常困惑。 我想要年龄值。

【问题讨论】:

  • 你能分享一下实际的错误信息吗?

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


【解决方案1】:

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

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

例子:

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

【讨论】:

    【解决方案2】:

    如果你想在 groovy 脚本中使用它,请参考这里

    getting inbound properties of ESB Mule message using Groovy

    这基本上告诉您可以将其用作

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

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

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

      • 在 mule 3.7 中工作
      【解决方案4】:

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

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

      【讨论】:

        【解决方案5】:

        这将作为入站属性出现。您可以使用 MEL 访问它:

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

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

        【讨论】:

          【解决方案6】:

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

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

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

          希望这会有所帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2012-12-04
            • 1970-01-01
            • 1970-01-01
            • 2014-10-30
            • 2014-11-01
            • 1970-01-01
            • 2014-03-02
            • 1970-01-01
            相关资源
            最近更新 更多