how to make camel simple expression work with property placeholder in spring xml

23,404

Solution 1

You can use the properties function from simple (http://camel.apache.org/simple)

<simple>${in.header.queuename} == ${properties:MQ.queuename1}</simple>

The {{ }} in nested < when > is likely due to a bug, that has been fixed in newer Camel releases.

Solution 2

From the route configuration that you have provided, It seems that you missed out setting queuename in header. Instead you should use properties component as

<simple>${properties:queuename} == 'MQ.queuename1'</simple>

Share:
23,404
David
Author by

David

Updated on July 09, 2022

Comments

  • David
    David almost 2 years

    I am trying to using property placeholder in camel route. I have test.properties which define property: MQ.queuename1=TESTQUEUE. In camel context, i define placeholder:

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

    In the route, i use simple expresion to evaluate the property:

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

    When i run camel, the property file is recognized by camel but it looks like the simple expression doesn't work. Do i miss anything?

  • David
    David about 10 years
    I have already set the value in the header (sorry for not put that setting in my question above). The camel route is working if i hard code the value ${in.header.queuename} == 'NI'. It only not working when i try to use property place holder.
  • David
    David about 10 years
    i have try your solution: <simple>${in.header.queuename} == 'MQ.queuename1'</simple>. But that does not work.
  • David
    David about 10 years
    Thanks a lot Claus. It works. I have bought your book Camel in Action. That is a great book for camel. Do you have plan for a new version of this book?
  • Claus Ibsen
    Claus Ibsen about 10 years
    Yeah if Camel keeps becoming more and more popular, and the sales of the current book is still good, then yeah the publisher is likely to agree on a 2nd ed.