On Fri, Aug 6, 2010 at 8:21 AM, unixployd <[email protected]> wrote:
>
> The code that creates routing looks like:
>
> from(fromUrl).process(new EmailProcessor());
>
> Actual EmailProcessor:
>
> public final class EmailProcessor implements Processor {
>
> private Log log = LogFactory.getLog(getClass());
>
> �...@produce(uri="log:foo")
> protected ProducerTemplate producer;
>
> public void process(Exchange exchange) throws Exception {
> log.info("producer is " + producer);
> }
>
> }
>
> So then starting up, Spring would handle this and would create one singleton
> of EmailProcessor in his context, if of course there would be defined bean
> in applicationContext.xml.
>
> Is it correct that this code should work and producer should not be null?
>
Ahhh you create the EmailProcessor instance yourself using the new operator.
Then neither Camel nor Spring has a chance to inject the dependencies.
You have to use Spring / Camel to look it up by its id. For example using Camel:
Processor email = context.getRegistry().lookup("myEmailProcessor",
Processor.class);
from(fromUrl).process(email);
Where context is CamelContext
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Spring-does-not-handle-Produce-tp2264524p2266328.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