camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From java kurious <javakuri...@gmail.com>
Subject Using Camel properties
Date Tue, 04 Mar 2014 16:45:10 GMT
Hi All,

I am using camel properties component to read properties file:

<bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="location"

value="classpath:META-INF/spring/code-to-value.properties"/>
</bean>



Everything works fine, except when I use a key that is not defined in the
properties file.

<camel:setHeader headerName="property-value-asdf">
           <simple>${properties:asdf}</simple>
</camel:setHeader>



In that case I get an error similar to following :

org.apache.camel.RuntimeCamelException:
java.lang.IllegalArgumentException: *Property
with key [asdf] not found in properties from text: {{asdf}}*
    at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1344)
    at
org.apache.camel.builder.ExpressionBuilder$76.evaluate(ExpressionBuilder.java:1733)
    at
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)
    at
org.apache.camel.builder.SimpleBuilder.evaluate(SimpleBuilder.java:83)
    at
org.apache.camel.builder.ProcessorBuilder$4.process(ProcessorBuilder.java:103)
    at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
    at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)
    at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)

What would be the right way to check if the key exists before using it ?

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message