camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanq <jqu...@abebooks.com>
Subject Re: Spring 3.0 and Camel 2.2 - Route configure() called before Spring beans injected
Date Mon, 03 May 2010 15:46:57 GMT

Claus,

That worked!  I changed my spring configuration to to the one below and
everything worked as expected.

  <camel:camelContext id="camel">
    <camel:routeBuilder ref="myRouteBuilderBean" />
  </camel:camelContext>

  <bean id="myRouteBuilderBean" class="com.example.MyRouteBuilder"
depends-on="camel">
    <property name="incomingEndpoint" value="file://C:\\triggerdir\\"/>
    <property name="myProcessor" ref="myProcessorBean"/>
  </bean> 

Thanks for the help!

Jonathan


Claus Ibsen-2 wrote:
> 
> Hi
> 
> Can you try with a depends-on="camel" attribute on the <bean> for the
> RouteBuilder to see if that helps.
> 
> 
> 
> 
> On Fri, Apr 30, 2010 at 8:36 PM, jonathanq <jquail@abebooks.com> wrote:
>>
>> I am having serious issues with Camel 2.2.0 and Spring 3.0.2.RELEASE.
>>
>> I am creating my route in spring as a bean and then injecting it into the
>> camelContext using the following:
>>
>>  <camel:camelContext id="camel">
>>    <camel:routeBuilder ref="myRouteBuilderBean" />
>>  </camel:camelContext>
>>
>>  <bean id="myRouteBuilderBean" class="com.example.MyRouteBuilder">
>>    <property name="incomingEndpoint" value="file://C:\\triggerdir\\"/>
>>    <property name="myProcessor" ref="myProcessorBean"/>
>>  </bean>
>>
>> The actual route definition is:
>>
>>  public void configure() throws Exception {
>>    from(getIncomingEndpoint())
>>            .convertBodyTo(String.class)
>>            .process(getMyProcessor());
>>  }
>>
>> There are getters/setters on the endpoint and the processor.
>>
>> The issue is that when camel starts up - it calls the "configure" on the
>> route builder BEFORE Spring has injected the bean with properties.
>>
>> So the getIncomingEndpoint() returns null - which will later cause Camel
>> to
>> fail saying you can't set a null uri (error:)
>>
>> If I change from using Spring 3.0.2.RELEASE to Spring 2.5.6.SR01 - this
>> issues goes away.  So it is definitely a camel 2.2.0 and Spring 3.0
>> issue.
>> It seems that Camel is trying to configure all of the routes before
>> Spring
>> has actually injected the beans.
>>
>> Note: the reason I am setting the value in Spring is that its actually
>> getting property-replaced.  However if you put a hardcoded string into
>> spring for the endpoint, its still not working.  So I know its not the
>> property replacement causing this.
>>
>> Like I said - works fine in Spring 2.5.6 and Camel 2.2.0 - but not Spring
>> 3.0.0.RELEASE, 3.0.1.RELEASE or 3.0.2.RELEASE.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Jonathan
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Spring-3.0-and-Camel-2.2---Route-configure%28%29-called-before-Spring-beans-injected-tp28415437p28415437.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Spring-3.0-and-Camel-2.2---Route-configure%28%29-called-before-Spring-beans-injected-tp28415437p28436749.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message