Thursday, March 12, 2009

Set the properties for Camel Context

If you want to do customer configuration on the inner component of Camel 2.0, how can you achieve that? You may say to use the system properties is a easy way.
But if I want to configure the component per camel context, as you know there could be more than one camel context per JVM.
I just introduced a property configuration per camel context in the Camel 2.0, so you want to configure the cachedOutputStream of Camel , you can do it like this.

With the java code

Map<String, String> properties = new HashMap<String, String>();
properties.put(CachedOutputStream.THRESHOLD, "1000");
properties.put(CachedOutputStream.TEMP_DIR, "/tmp/camel");
camelContext..setProperties(properties);



With Spring configuration

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<properties>
<property key="CamelCachedOutputStreamThreshold" value="10000"/>
</properties>
<property key="CamelCachedOutputStreamOutputDirectory" value="/tmp/camel"/>
</properties>
<property key="the key of properties" value="the value as string"/>
</properties>
...
<camelContext>

4 comments:

  1. I want to know how class loading happens in servicemix in details can you get me some reference. I got into a problem like , with jars in smx/lib my application performs better than having jar's as shared lib, why it so

    ReplyDelete
  2. servicemix 3's classloader is like the classical application server's classloader, SMX/lib's jars can be saw from all the SA, and the shared lib jars can be saw by the SA which holds the reference of the shared lib.

    If you have some jars which may introduce some conflict with other SA, you'd better to use shared lib instead of the copy the jars to SMX/lib.

    For ServiceMix4, we are using OSGi, that is another story of classloader :)

    ReplyDelete
  3. Wow what a nice post.I am felling glad about this post.Can you more share with me.I have many ideas about it.

    Thanks for more sharing.....



    zvnproperties

    ReplyDelete
  4. Just a tip, to access the property in a just use: ${property.PROPERTY_NAME}

    ReplyDelete