You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Matteo Cusmai <cu...@gmail.com> on 2013/12/14 09:24:42 UTC

different context

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

Re: different context

Posted by Claus Ibsen <cl...@gmail.com>.
No there is no performance issues. Its intra-jvm communication which
is as fast as possible.

Though for some high end cases the disruptor implementation of the
queues has proven faster.
http://camel.apache.org/disruptor.html

You can find link to the disruptor project from that link above and
find more details on the internet.


On Wed, Dec 18, 2013 at 9:46 AM, Matteo Cusmai <cu...@gmail.com> wrote:
> Hi all,
> Could you please tell me if there are performance issues using vm component
> to connect 2 camel context?
> Is there any specific documentation about it.
>
> Thanks in advance,
> Matteo.
> On 15 Dec 2013 01:07, "Matteo Cusmai" <cu...@gmail.com> wrote:
>
>> Hi Robert,
>> I know that article, it is part of camel in action book that i have read.
>> The problem is that he use scala api, and it is different and poorer than
>> java api.
>> On 14 Dec 2013 16:37, "kraythe ." <kr...@gmail.com> wrote:
>>
>>> Try out this article:
>>>
>>>
>>> https://weblogs.java.net/blog/manningpubs/archive/2013/02/13/akka-and-camel
>>>
>>> You can init the Akka Camel context with spring and get the best of both
>>> worlds.
>>>
>>> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
>>> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
>>> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
>>> <http://www.linkedin.com/pub/robert-simmons/40/852/a39>*
>>>
>>>
>>> On Sat, Dec 14, 2013 at 4:52 AM, Matteo Cusmai <cusmaimatteo@gmail.com
>>> >wrote:
>>>
>>> > Hi Claus,
>>> > I am talking about this issue with Akka community in their mailing
>>> list, I
>>> > am waiting an answer.
>>> > In the mean time I am trying to figure out my solution to the issue.
>>> >
>>> > However, regarding to manage 2 different camel contexts I read this
>>> link "
>>> > http://camel.apache.org/context.html", and I have found the solution I
>>> > wrote in the first my email.
>>> > Thanks to your suggestion, I have experienced that it works good with
>>> > direct-vm and vm, without camel-context dependency.
>>> >
>>> > So, just to know, could you explain me which are the differences between
>>> > camel-context and vm approaches?
>>> > Which are the pros and cons?
>>> >
>>> > Cheers,
>>> > Matteo.
>>> >
>>> >
>>> > Matteo Cusmai
>>> >
>>> >
>>> > On Sat, Dec 14, 2013 at 11:10 AM, Claus Ibsen <cl...@gmail.com>
>>> > wrote:
>>> >
>>> > > 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" <cl...@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
>>> > >
>>> >
>>>
>>



-- 
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

Re: different context

Posted by Matteo Cusmai <cu...@gmail.com>.
Hi all,
Could you please tell me if there are performance issues using vm component
to connect 2 camel context?
Is there any specific documentation about it.

Thanks in advance,
Matteo.
On 15 Dec 2013 01:07, "Matteo Cusmai" <cu...@gmail.com> wrote:

> Hi Robert,
> I know that article, it is part of camel in action book that i have read.
> The problem is that he use scala api, and it is different and poorer than
> java api.
> On 14 Dec 2013 16:37, "kraythe ." <kr...@gmail.com> wrote:
>
>> Try out this article:
>>
>>
>> https://weblogs.java.net/blog/manningpubs/archive/2013/02/13/akka-and-camel
>>
>> You can init the Akka Camel context with spring and get the best of both
>> worlds.
>>
>> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
>> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
>> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
>> <http://www.linkedin.com/pub/robert-simmons/40/852/a39>*
>>
>>
>> On Sat, Dec 14, 2013 at 4:52 AM, Matteo Cusmai <cusmaimatteo@gmail.com
>> >wrote:
>>
>> > Hi Claus,
>> > I am talking about this issue with Akka community in their mailing
>> list, I
>> > am waiting an answer.
>> > In the mean time I am trying to figure out my solution to the issue.
>> >
>> > However, regarding to manage 2 different camel contexts I read this
>> link "
>> > http://camel.apache.org/context.html", and I have found the solution I
>> > wrote in the first my email.
>> > Thanks to your suggestion, I have experienced that it works good with
>> > direct-vm and vm, without camel-context dependency.
>> >
>> > So, just to know, could you explain me which are the differences between
>> > camel-context and vm approaches?
>> > Which are the pros and cons?
>> >
>> > Cheers,
>> > Matteo.
>> >
>> >
>> > Matteo Cusmai
>> >
>> >
>> > On Sat, Dec 14, 2013 at 11:10 AM, Claus Ibsen <cl...@gmail.com>
>> > wrote:
>> >
>> > > 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" <cl...@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
>> > >
>> >
>>
>

Re: different context

Posted by Matteo Cusmai <cu...@gmail.com>.
Hi Robert,
I know that article, it is part of camel in action book that i have read.
The problem is that he use scala api, and it is different and poorer than
java api.
On 14 Dec 2013 16:37, "kraythe ." <kr...@gmail.com> wrote:

> Try out this article:
>
> https://weblogs.java.net/blog/manningpubs/archive/2013/02/13/akka-and-camel
>
> You can init the Akka Camel context with spring and get the best of both
> worlds.
>
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
> <http://www.linkedin.com/pub/robert-simmons/40/852/a39>*
>
>
> On Sat, Dec 14, 2013 at 4:52 AM, Matteo Cusmai <cusmaimatteo@gmail.com
> >wrote:
>
> > Hi Claus,
> > I am talking about this issue with Akka community in their mailing list,
> I
> > am waiting an answer.
> > In the mean time I am trying to figure out my solution to the issue.
> >
> > However, regarding to manage 2 different camel contexts I read this link
> "
> > http://camel.apache.org/context.html", and I have found the solution I
> > wrote in the first my email.
> > Thanks to your suggestion, I have experienced that it works good with
> > direct-vm and vm, without camel-context dependency.
> >
> > So, just to know, could you explain me which are the differences between
> > camel-context and vm approaches?
> > Which are the pros and cons?
> >
> > Cheers,
> > Matteo.
> >
> >
> > Matteo Cusmai
> >
> >
> > On Sat, Dec 14, 2013 at 11:10 AM, Claus Ibsen <cl...@gmail.com>
> > wrote:
> >
> > > 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" <cl...@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
> > >
> >
>

Re: different context

Posted by "kraythe ." <kr...@gmail.com>.
Try out this article:

https://weblogs.java.net/blog/manningpubs/archive/2013/02/13/akka-and-camel

You can init the Akka Camel context with spring and get the best of both
worlds.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Sat, Dec 14, 2013 at 4:52 AM, Matteo Cusmai <cu...@gmail.com>wrote:

> Hi Claus,
> I am talking about this issue with Akka community in their mailing list, I
> am waiting an answer.
> In the mean time I am trying to figure out my solution to the issue.
>
> However, regarding to manage 2 different camel contexts I read this link "
> http://camel.apache.org/context.html", and I have found the solution I
> wrote in the first my email.
> Thanks to your suggestion, I have experienced that it works good with
> direct-vm and vm, without camel-context dependency.
>
> So, just to know, could you explain me which are the differences between
> camel-context and vm approaches?
> Which are the pros and cons?
>
> Cheers,
> Matteo.
>
>
> Matteo Cusmai
>
>
> On Sat, Dec 14, 2013 at 11:10 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
>
> > 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 <cu...@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" <cl...@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
> >
>

Re: different context

Posted by Matteo Cusmai <cu...@gmail.com>.
Hi Claus,
I am talking about this issue with Akka community in their mailing list, I
am waiting an answer.
In the mean time I am trying to figure out my solution to the issue.

However, regarding to manage 2 different camel contexts I read this link "
http://camel.apache.org/context.html", and I have found the solution I
wrote in the first my email.
Thanks to your suggestion, I have experienced that it works good with
direct-vm and vm, without camel-context dependency.

So, just to know, could you explain me which are the differences between
camel-context and vm approaches?
Which are the pros and cons?

Cheers,
Matteo.


Matteo Cusmai


On Sat, Dec 14, 2013 at 11:10 AM, Claus Ibsen <cl...@gmail.com> wrote:

> 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 <cu...@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" <cl...@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 <cu...@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
>

Re: different context

Posted by Claus Ibsen <cl...@gmail.com>.
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 <cu...@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" <cl...@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 <cu...@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

Re: different context

Posted by Matteo Cusmai <cu...@gmail.com>.
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" <cl...@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 <cu...@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
>

Re: different context

Posted by Claus Ibsen <cl...@gmail.com>.
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 <cu...@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