camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject Re: Camel 2.0 - pass uri reference using variable ${my_Uri}
Date Tue, 05 May 2009 11:24:21 GMT
Many thanks Claus,

Based on the link provided and feedback received from Costin Leau, here is
what I have done to resolve the issue :

To work with the following uri :

file://d:/temp/data/?move=d:/temp/done/${file.name}

in your camel route and define it in a property file,

here is what you have to do

*Step 1 : Create
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer bean
*

Define a PropertyPlaceHolder (using another prefix/suffix delimiter) to
avoid conflict between your camel variable and Spring property

    <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="placeholderPrefix" value="#{"/> (1)
        <property name="placeholderSuffix" value="}" /> (2)
        <property name="location"
value="classpath:META-INF/spring/org.apache.camel.example.reportincident.routing.properties"
/> (2)
    </bean>

(1) : Define a different prefix instead of ${ which is the value by default
and used as variab
(2) : Define the value of the suffix. In this case, this is the same as the
default value

*Step 2 : Create org.apache.camel.example.reportincident.routing.properties*

Create the following file :
org.apache.camel.example.reportincident.routing.properties and put it in
your classpath. If you plan to deploy your camel route under Apache
ServiceMix Kernel --> Apache Karaf, add this file in the META-INF/spring
directory by example
Add the following property :

uriFile=file://d:/temp/data/?move=d:/temp/done/${file.name}

*Step 3 : Create an endpoint in your Camel Spring DSL file*

 Create a camel endpoint for the uri that you would like to use

<camel:endpoint id="fileEndpoint" uri="#{uriFile}"/> (1)

(1) As you can see, we use as a Spring variable reference the syntax #{} so
spring will retrieve the value from the variable declared in the file

*Step 4 : Adapt your route*

Define the uri of your route like this :

<camel:from ref="fileEndpoint" />

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Tue, May 5, 2009 at 9:31 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> Hi
>
> Last time we checked it required Spring 3.0 as Spring 2.5 did not
> support the property placeholders in custom namespace handlers.
> There is a ticket in Camel JIRA that has a link to the ticket in Spring
> JIRA.
>
> However if you define you endpoints with the <endpoint id="xxx"
> uri="${foo}"/>
> then you can use property placeholders.
>
> There is also a FAQ about this:
>
> http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html
>
>
> On Tue, May 5, 2009 at 9:23 AM, Charles Moulliard <cmoulliard@gmail.com>
> wrote:
> > Hi,
> >
> > I would like to know if something is planned to support uri declaration
> for
> > Camel routes using variable like by example : ${my_Uri}
> >
> > e.g.
> >
> > <camel:route>
> > <camel:from uri="${uriFile}" />
> >    <camel:setHeader headerName="origin">
> >        <camel:constant>file</camel:constant>
> >    </camel:setHeader>
> > <camel:unmarshal ref="bindyDataformat" />
> > <camel:to uri="${queueIn}" />
> > </camel:route>
> >
> > and
> >
> > osgix:cm-properties like this
> >
> > <osgix:cm-properties id="camelProps"
> > persistent-id="org.apache.camel.example.reportincident.routing">
> >    <prop
> key="uriFile">file://c:/temp/data/?move=c:/temp/done/${file:name}<file:///c:/temp/data/?move=c:/temp/done/$%7Bfile:name%7D></prop>
> > (2)
> >    <prop key="queueIn">queuingservice:queue:in</prop> (1)
> > </osgix:cm-properties>
> >
> > <context:property-placeholder properties-ref="camelProps">
> >
> > Remarks :
> > - ${file:name} is a camel property so we will have issues with Spring
> > because ${ and } are reserved characters
> > - The example provided here generates Camel error : see
> > https://issues.apache.org/activemq/browse/CAMEL-1577
> >
> > Regards,
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> Apache Camel Reference Card:
> http://refcardz.dzone.com/refcardz/enterprise-integration
> Interview with me:
>
> http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress
>

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