camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kraythe ." <kray...@gmail.com>
Subject Re: different context
Date Sat, 14 Dec 2013 15:37:19 GMT
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 <claus.ibsen@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" <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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message