camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrique Viecili <henri...@myreks.com>
Subject Re: Dynamic route ids with Spring DSL
Date Tue, 20 Nov 2012 20:23:57 GMT
I tried in many different ways to set a dynamic route id (see below), but
apparently the id receives the raw string as I checked with jconsole. The
log endpoint ids received the property value as expected
(some.namespace=NAMESPACE).

I also tried to use a property for the camelContext id, which gave me the
exception:
Error creating bean with name '${some.namespace}': Cannot resolve reference
to bean 'NAMESPACE:beanPostProcessor' while setting bean property
'beanPostProcessor'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'NAMESPACE:beanPostProcessor' is defined


this is the camel-context I tested:
<beans> [...]
   <util:properties id="props" location="classpath:namespace.properties" />

    <context:property-placeholder properties-ref="props"/>

    <bean id="namespace" class="java.lang.String"><constructor-arg
value="${some.namespace}"/></bean>

    <camel:camelContext id="camel-context" trace="true" >
        <camel:propertyPlaceholder id="properties"
location="ref:props"/>

        <camel:route id="#{'GENERIC-route-'+namespace}">
            <camel:from uri="direct:start"/>
            <camel:to uri="log:started-{{some.namespace}}"/>
        </camel:route>

        <camel:route id="${some.namespace}-route">
            <camel:from uri="direct:start2"/>
            <camel:to uri="log:started2-{{some.namespace}}"/>
        </camel:route>

        <camel:route id="{{some.namespace}}">
            <camel:from uri="direct:start3"/>
            <camel:to uri="log:started3-{{some.namespace}}"/>
        </camel:route>
    </camel:camelContext>

</beans>




*Henrique Viecili*
Myreks



On Tue, Nov 20, 2012 at 12:57 PM, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> On Mon, Nov 19, 2012 at 9:48 PM, Henrique Viecili <henrique@myreks.com>
> wrote:
> > Is it possible to set the route id attribute with a dynamic value? (in
> > Spring DSL)
> >
> > Example:
> >
> > <camel:route id="my-route-{{suffix}}"/>
> >
> > and 'suffix' comes from a property file.
> >
>
> Have you tried
>
> Camel's property placeholder on the DSL is applies on all the
> setter/getters on the model. So from Camel point of view, there is a
> getId/setId option.
>
> Though that's usully applied to the content inside a route. On the
> <route> itself I am actually not sure the "id" attribute is.
>
> Though give it a try and report back.
>
>
>
> >
> > *Henrique Viecili*
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

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