Groovy Mule 3动态检索占位符值

Groovy Mule 3动态检索占位符值,groovy,mule,mule-esb,mule-el,Groovy,Mule,Mule Esb,Mule El,我有一个用例,需要从属性文件中检索值,但该键应该从查询参数中动态派生 如何在MEL或Groovy中处理此问题?我知道这在DW是可能的 Http request https://localhost:9898/getStore?search=customer.weststore.name 我的占位符是- file.properties customer.weststore.name=TESTING customer.eaststore.name=IRERRER 所以我需要这样的方式来访问这样的东

我有一个用例,需要从属性文件中检索值,但该键应该从查询参数中动态派生

如何在MEL或Groovy中处理此问题?我知道这在DW是可能的

Http request
https://localhost:9898/getStore?search=customer.weststore.name
我的占位符是-

file.properties
customer.weststore.name=TESTING
customer.eaststore.name=IRERRER
所以我需要这样的方式来访问这样的东西

<set-variable variableName="westDetail" value="#[message.inboundProperites['customer.weststore.name']" doc:name="Variable"/>
<logger message="${westDetail}" level="INFO" /> --> Failed as no placeholder available

-->失败,因为没有可用的占位符
当我尝试上面的方法时,它失败了,因为没有占位符作为“westDetail”可用,而我需要从属性文件中获取特定的键

这与本文有关,但DW提供的唯一解决方案不是MEL或Groovy


有人怎么建议,这可能吗?

我知道问题是您希望通过执行时获得的密钥查询属性

你做得不对<代码>${}用于评估属性的值,这是在应用程序初始化时完成的。您错过了获取集合变量中的实际值的步骤

#[]
用于执行MEL表达式,该表达式在执行时发生
flowVars.westDetail
是一个MEL表达式,返回流变量westDetail的值。不能使用MEL表达式计算属性占位符
${}
,因为它们在不同的时间计算

解决方案是使用Springbean来存储属性,而不是配置属性占位符。然后您可以将其指定给流变量,并像映射一样访问它

例如:

<spring:beans>
  <spring:bean id="myProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <spring:property name="location" value="classpath:items.properties"/>      
  </spring:bean>    
</spring:beans>

<flow name="myFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <set-variable value="#[app.registry.myProperties]" variableName="props"></set-variable>
    <logger message="a=#[flowVars.props['a']]" level="INFO"/>
</flow>
输出:

a=1

谢谢,但正如我在用例中提到的,它动态地传递flowVars来读取属性值,因此最终变量的值和键名应该是相同的。这是我试图探讨的实际问题——应该更新问题以澄清这一点。问题应该是自包含的,不依赖于外部链接。只更新了我的编辑及其自包含,但类似于用例。
a=1