在Mule Flow中将属性加载为Map

时间:2014-03-24 12:29:45

标签: mule

我目前正在使用Mule ESB 3.4。为了在运行时配置属性并加载.properties文件,我使用Mule property-placeholder组件。当密钥本身是动态的时,我需要提取属性值。例如;我必须将多个应用程序的URL存储在属性文件中(如查找表)。这里我的关键是app id,值是URL。我需要根据作为请求的一部分提供给mule-flow的app Id来检索URL。有没有办法实现这个目标?应用程序的数量可以是10-15。所以我不想将它存储在数据库中并检索它。有没有办法使用mule via配置实现它?

1 个答案:

答案 0 :(得分:4)

您可以使用Spring将它们直接加载到地图中:

 <spring:beans>
        <spring:bean id="appProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
            <spring:property name="singleton" value="true"/>
            <spring:property name="location" value="classpath:application.properties"/>
        </spring:bean>
    </spring:beans>

使用MEL类似于:

在您的流程中动态访问它
 <logger message="My prop #[app.registry.appProps[flowVars.someKey]]" level="INFO" />

使用您想要检索动态密钥来替换flowVars.someKey。

相关问题