camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: different context
Date Sat, 14 Dec 2013 10:10:46 GMT
Oh dear maybe try to get the akka people to make this better, so you
can use a spring based camel with their stuff more easily.

If you want to integrate 2 different camel contexts in the same jvm,
then try with direct-vm or the vm component.

On Sat, Dec 14, 2013 at 10:03 AM, Matteo Cusmai <cusmaimatteo@gmail.com> wrote:
> 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" <claus.ibsen@gmail.com> 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 <cusmaimatteo@gmail.com>
>> 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&amp;queue=rewardAquire1&amp;username=guest&amp;password=guest&amp;routingKey=S1111BBB&amp;autoDelete=false&amp;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: cibsen@redhat.com
>> 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
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
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

Mime
View raw message