Hi Claus, Thanks for rapid answer. I agree with you, but the problem is that I am using akka camel extension that creates a default camel context by itself. I don't think it is a good idea scanning akka packaging to look for route builders. My idea is to use 2 different context, mine based on spring xml and akka one based on default.
What do you think about? Cheers, On 14 Dec 2013 09:37, "Claus Ibsen" <[email protected]> wrote: > No, its better to have 1 camel context. And from the spring camel > context, you can refer to a <routeBuilder ref> or use package scanning > to find and add your java dsl route builder classes. > > See the documentation > http://camel.apache.org/spring > > On Sat, Dec 14, 2013 at 9:24 AM, Matteo Cusmai <[email protected]> > wrote: > > Hi all, > > I am trying to use different camel context in my app. > > > > I have a camel context based on spring: > > > > <beans xmlns="http://www.springframework.org/schema/beans" > >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > >> xsi:schemaLocation=" > >> http://www.springframework.org/schema/beans > >> http://www.springframework.org/schema/beans/spring-beans.xsd > >> http://camel.apache.org/schema/spring > >> http://camel.apache.org/schema/spring/camel-spring.xsd"> > >> > >> <camelContext xmlns="http://camel.apache.org/schema/spring" > >> id="externalContext"> > >> > >> <route> > >> <from > >> > uri="rabbitmq://localhost/SIM_DATA?exchangeType=topic&queue=rewardAquire1&username=guest&password=guest&routingKey=S1111BBB&autoDelete=false&threadPoolSize=1" > >> /> > >> <to uri="direct:consumer1" /> > >> </route> > >> > >> </camelContext> > >> > >> </beans> > >> > >> > > and a second one based on java dsl: > > > > public class MainCamel { > > > > public static void main(String[] args) throws Exception { > > > > CamelContext externalContext = new > > ClassPathXmlApplicationContext("META-INF/camel-context.xml").getBean( > > "externalContext", CamelContext.class ); > > > > DefaultCamelContext context = new DefaultCamelContext(); > > context.setRegistry( externalContext.getRegistry() ); > > > > context.addRoutes( new RouteBuilder() { > > @Override > > public void configure() throws Exception { > > > from("context:externalContext:consumer1").to("stream:out"); > > } > > }); > > > > context.start(); > > > > Thread.sleep( 60000 ); > > > > context.shutdown(); > > externalContext.stop(); > > > > } > > > > } > > > > > > > > I am using camel 2.12.2 (core, rabbit, stream and context). > > It seems to work, my question is: > > is my code the right way to integrate a spring camel context with a java > > dsl one? > > > > > > Thanks in advance, > > > > > > Matteo Cusmai > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > Email: [email protected] > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > Make your Camel applications look hawt, try: http://hawt.io >
