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
