camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Strachan <>
Subject Re: Spring-DM and ProducerTemplate
Date Wed, 04 Feb 2009 13:24:52 GMT
2009/2/3 paquettd <>:
> So I have a spring file that looks something like this. I'm using Spring-DM
> and Camel 1.5.0. So this file is in META-INF/spring in my OSGi bundle.
>    <camelContext id="camelcontext"
> xmlns="">
>        <route>
>            <from uri="direct:testDirect"/>
>            <to uri="stream:err"/>
>        </route>
>    </camelContext>
>    <camel:template id="myCamelTemplate"/>
>    <bean id="myBean" class="myClass">
>        <property name="producerTemplate" ref="myCamelTemplate"/>
>    </bean>
> So what I've found is that if I sleep for a few hundred milliseconds in my
> bean after receiving the producer template I can then send a string to
> direct:testDirect and it will print out on stderr. However, if I use the
> template right away without sleeping I see
> [SpringOsgiExtenderThread-2] WARN
> - No getConsumers()
> available on Producer[direct:testDirect] for Exchange[Message: Hello World]
> and no message is ever printing. Clearly there is some kind of race here.
> What do I need to do so that I can be positive the camel context is up and
> ready. I tried casting it to DefaultCamelContext and using the isStarted
> method but that doesn't do it. It looks like that starts returning true
> before everything is necessarily up and running.
> Am I missing something obvious?

I wonder if you use the @Produce annotation to get camel to inject it
into your bean, it avoids the ordering issues?

Open Source Integration

View raw message