从defaultMuleMessage获取值

时间:2016-12-02 11:50:48

标签: mule anypoint-studio mel

我正在尝试从defaultMuleMessage数据类型中提取值,但无法在Mule 3.7.3中获得正确的语法。有人可以帮忙吗?

我试图访问的值可以在Mule调试器的变量选项卡中找到:

initialMessage (org.mule.DefaultMuleMessage)
-> properties (org.mule.MessagePropertiesContext)
--> inboundMap (org.mule.util.CopyOnWrite.CaseInsensitiveMap)
---> 7 (java.util.Collections$UnmodifiavleMap$UnmodifiableEntrySet$UnmodifiableEntry)

7是键=组织

如果我在调试器中键入“initialMessage”,我会收到:

org.mule.DefaultMuleMessage
{
  id=6980b240-b882-11e6-85f7-d26120524153
  payload=java.lang.String
  correlationId=<not set>
  correlationGroup=-1
  correlationSeq=-1
  encoding=UTF-8
  exceptionPayload=<not set>

Message properties:
  INVOCATION scoped properties:
    _ApikitResponseTransformer_apikitRouterRequest=yes
    _ApikitResponseTransformer_bestMatchRepresentation=application/json
    _ApikitResponseTransformer_contractMimeTypes=[MimeType{type='application/json'}]
    counter=1
    deterministicOrchestration=true
    initialMessage=<<<MuleMessage>>>
    logLevel=INFO
    maskingEnabled=true
    messageFormat=JSON
    messageLocation=CLIENT_REQUEST
    mongoOperation=insert-object-from-map
    mongoQuery={messageLocation=client_request, payload={NullPayload}}
    mongoSynchronous=false
    nextOrchestratedFlow=products-getProducts
    orchestrationFlows=[products-getProducts]
    prevResponse=''
  INBOUND scoped properties:
    accept=*/*
    accept-encoding=gzip, deflate, peerdist
    accept-language=en-GB
    organization=abc
    connection=Keep-Alive
    host=localhost:8089
    http.listener.path=/api/*
    http.method=GET
    http.query.params=ParameterMap{[]}
    http.query.string=
    http.remote.address=/127.0.0.1
    http.request.path=/api/products
    http.request.uri=/api/products
    http.scheme=http
    http.uri.params=ParameterMap{[]}
    http.version=HTTP/1.1
    referer=http://localhost:8089/api/console/
    ua-cpu=AMD64
    user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; managedpc; rv:11.0) like Gecko
    x-p2p-peerdist=Version=1.0
    x-requested-with=XMLHttpRequest
  OUTBOUND scoped properties:
    Content-Type=text/plain;charset=UTF-8
    MULE_ENCODING=UTF-8
  SESSION scoped properties:
    country=usa
    resource=products
}

我正在尝试检索“organization = abc”值。

由于

3 个答案:

答案 0 :(得分:0)

如果您想使用MEL从mule消息获取入站属性(例如,名为organization),您只需:

#[message.inboundProperties.'organization']

答案 1 :(得分:0)

我可以从问题和前一个答案的评论中得到。

您正在寻找MuleMessage的入站属性,该MuleMessage本身可作为您的流程消息中的属性。

尝试以下解决方案。

#[message.inboundProperties.'initialMessage'.getInboundProperty('organization')]

希望这有帮助。

答案 2 :(得分:0)

尝试这样,#[message.inboundProperties.organization]