camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Punnoose, Roshan" <punnoo...@bah-systems.com>
Subject Camel Pojo Routing
Date Wed, 01 Aug 2007 16:15:41 GMT
I couldn't get the forums to come up, it keeps timing out, so I have to
ask this question on the mailing list.

 

I have two Pojo endpoints, and I want to route based on a String input.
How do I do that? This is my code currently:

 

CamelContext context = new DefaultCamelContext();

                        PojoComponent component1 = (PojoComponent)
context.getComponent("pojo");

                        component1.addService("one", new PojoOne());

                        PojoComponent component2 = (PojoComponent)
context.getComponent("pojo");

                        component2.addService("two", new PojoTwo());

 

                        DirectComponent directComponent =
(DirectComponent) context

                                                .getComponent("direct");

                        directComponent.createEndpoint("hello");

 

                        context.addRoutes(new RouteBuilder() {

                                    public void configure() {

                                                FromBuilder from =
from("direct:hello");

                                                ChoiceBuilder choice =
from.choice();

                                                WhenBuilder when =
choice

 
.when(body().isEqualTo("One"));

                                                when.to("pojo:one")

 
.otherwise().to("pojo:two");

                                    }

                        });

 

                        context.start();

 

                        Endpoint endpoint =
context.getEndpoint("direct:hello");

                        PojoNumInterface pojo = (PojoNumInterface)
PojoComponent.createProxy(

                                                endpoint,
PojoNumInterface.class);

                        pojo.execute("One");

 

 

I'm guessing the body() function only returns a PojoInvocation and not
the actual argument "One".

 

Roshan


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message