如何使用spring xml中的属性占位符使camel简单表达式工作

Dav*_*vid 4 spring expression properties placeholder apache-camel

我想在驼峰路线中使用属性占位符.我有test.properties定义属性:MQ.queuename1 = TESTQUEUE.在camel上下文中,我定义了占位符:

<camel:camelContext xmlns="http://camel.apache.org/schema/spring" >
  <propertyPlaceholder id="camel-properties"  location="file:${web.external.propdir}/test.properties"/>
Run Code Online (Sandbox Code Playgroud)

在路线中,我使用简单的表达来评估属性:

<choice>
           <when>
                <simple>${in.header.queuename} == '{{MQ.queuename1}}'</simple>
            <bean ref="ExtractOrderContent" method="extractContent"/>
                <to uri="websphere-mq:queue:TESTQUEUE" pattern="InOnly"/>
            </when> 
        </choice>
Run Code Online (Sandbox Code Playgroud)

当我运行camel时,属性文件被camel识别,但看起来简单的表达式不起作用.我什么都想念?

Cla*_*sen 13

您可以使用简单的属性函数(http://camel.apache.org/simple)

<simple>${in.header.queuename} == ${properties:MQ.queuename1}</simple>
Run Code Online (Sandbox Code Playgroud)

嵌套<when>中的{{}}可能是由于一个bug,已在较新的Camel版本中修复.

  • 是的,如果Camel越来越受欢迎,并且当前图书的销售情况仍然不错,那么发布者可能会同意第二版. (2认同)