【问题标题】:Loading properties as Map in a Mule Flow在 Mule Flow 中将属性加载为地图
【发布时间】:2014-03-24 12:29:44
【问题描述】:

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

【问题讨论】:

    标签: mule


    【解决方案1】:

    您可以像这样使用 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 替换为您想要检索的动态密钥。

    【讨论】:

    • @RyanCarter 你能为 Mule 3.7 提出同样的建议吗?
    猜你喜欢
    • 2013-05-27
    • 2016-08-30
    • 1970-01-01
    • 2020-09-18
    • 1970-01-01
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多