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 <[email protected]> wrote:
> On Mon, Nov 19, 2012 at 9:48 PM, Henrique Viecili <[email protected]>
> 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: [email protected]
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>