how to make camel simple expression work with property placeholder in spring xml
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>
David
Updated on July 09, 2022Comments
-
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 about 10 yearsI 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 about 10 yearsi have try your solution: <simple>${in.header.queuename} == 'MQ.queuename1'</simple>. But that does not work.
-
David about 10 yearsThanks 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 about 10 yearsYeah 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.