2 Replies Latest reply on Feb 26, 2015 5:40 AM by Nitesh jain

    How to get the System Environment variable inside camel context

    Nitesh jain Newbie

      I have a system variable "JBOSS_FUSE_HOME" and in my camel context i tried this

       

      <camelContext trace="false" id="Camel"  xmlns="http://camel.apache.org/schema/spring">

      .....

      .....

           <route id="loadtoMemory">

                  <from  uri="cxf:bean:demo-ws" />

                  <process ref="responseCacheLoadingAction" />

                  <log message="${JBOSS_FUSE_HOME}"/>

        </route>

      </camelContext>

       

      Exception in thread "SpringOsgiExtenderThread-14" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route loadtoMemory at: >>> Log[${JBOSS_FUSE_HOME}] <<< in route: Route(loadtoMemory)[[From[cxf:bean:demo-ws... because of Unknown function: JBOSS_FUSE_HOMEat location 0

      ${JBOSS_FUSE_HOME}

      *

      any help on how to access the System environment variables in camel context.xml would be appreciated.

       

      Thanks,

      Nitesh

        • 1. Re: How to get the System Environment variable inside camel context
          bharadwaj n Novice

          Using system and environment variables in locations

           

          Available as of Camel 2.7

           

          The location now supports using placeholders for JVM system properties and

          OS environments variables.

           

          For example:

          location=file:${karaf.home}/etc/foo.properties

           

          In the location above we defined a location using the file scheme using the

          JVM system property with key karaf.home.

           

          To use an OS environment variable instead you would have to prefix with env:

          location=file:$/etc/foo.properties

           

          Where APP_HOME is an OS environment.

           

          You can have multiple placeholders in the same location, such as:

          location=file:$/etc/${prop.name}.properties

          Using out of the box functions

           

          Available as of Camel 2.14.1

           

          The Properties

          1 of 1 people found this helpful
          • 2. Re: How to get the System Environment variable inside camel context
            Nitesh jain Newbie

            Thanks Bhardwaj, That helped me , below is my camel context.

             

            <camelContext trace="false" id="Camel"  xmlns="http://camel.apache.org/schema/spring">

            .....

            .....

                 <route id="loadtoMemory">

                        <from  uri="cxf:bean:demo-ws" />

                        <log message="Hi this is{{myName}}"/>

              </route>

            </camelContext>

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

                   <property name="location"  value="file:${env:JBOSS_FUSE_HOME}/conf/test.properties" />

            </bean>

             

            2015-02-26 16:01:37,387 | INFO l loadtoMemory       ? | 158 - org.apache.camel.camel-core - 2.12.0.redhat-610379 | Hi this is xyz

             

            Regards,

            Nitesh