使用Groovy获取ESB Mule消息的入站属性
我有groovy transformer组件,它将获取入站属性并在flow vars中设置它,如下所示使用Groovy获取ESB Mule消息的入站属性,groovy,mule,esb,Groovy,Mule,Esb,我有groovy transformer组件,它将获取入站属性并在flow vars中设置它,如下所示 if(message.inboundProperties.'http.query.params'.Brand != null){ flowVars ['Brand'] = message.inboundProperties.'http.query.params'.Brand } return payload; 但我得到低于指定的错误。似乎inboundProperties不在groo
if(message.inboundProperties.'http.query.params'.Brand != null){
flowVars ['Brand'] = message.inboundProperties.'http.query.params'.Brand
}
return payload;
但我得到低于指定的错误。似乎inboundProperties不在groovy的范围内。您能告诉我如何在groovy中访问入站属性吗
注意:我不想改变有效载荷。我的目标是基于queryparms创建flowVars
部分错误:
No such property: inboundProperties for class: org.mule.DefaultMuleMessage (groovy.lang.MissingPropertyException)
org.codehaus.groovy.runtime.ScriptBytecodeAdapter:51 (null)
我看不到
getInboundProperties()
方法
我猜你想要:
if(message.getInboundProperty('http.query.params')?.Brand){
flowVars ['Brand'] = message.getInboundProperty('http.query.params').Brand
}
我看不到
getInboundProperties()
方法
我猜你想要:
if(message.getInboundProperty('http.query.params')?.Brand){
flowVars ['Brand'] = message.getInboundProperty('http.query.params').Brand
}
有两个选项可以从入站属性设置变量:
替换为
if(message.getInboundProperty('http.query.params').get('Brand') != null) {
flowVars ['Brand'] = message.getInboundProperty('http.query.params').get('Brand');
}
return payload;
有两个选项可以从入站属性设置变量:
替换为
if(message.getInboundProperty('http.query.params').get('Brand') != null) {
flowVars ['Brand'] = message.getInboundProperty('http.query.params').get('Brand');
}
return payload;
使用message.getInboundProperty
def brand = message.getInboundProperty('http.query.params').Brand
if (brand != null){
flowVars ['Brand'] = brand
}
return payload;
使用message.getInboundProperty
def brand = message.getInboundProperty('http.query.params').Brand
if (brand != null){
flowVars ['Brand'] = brand
}
return payload;
如果getInboundProperty返回Null,将为您提供一个NPE如果getInboundProperty返回nullThe,将为您提供一个NPE?检查null对我来说是一种新语法。谢谢分享。是什么?检查null对我来说是一种新语法。谢谢分享。