Hi.

You can use camel in your java class like this:

@EndpointInject(uri="direct:start")

protected ProducerTemplate start;

...

start.sendBody(body);


The route should look like this:

from("direct:start")  // This is a java class and the message is a java object.
.choice()
.when(simple("${body.ID}=='A'")).to("serverX")
.when(simple("${body.ID}=='B'")).to("serverY")
.otherwise().to("serverZ")
.end();

For me it's not clear, what do you mean by server? Are the destination classes are in your context (e.g. spring)? IF yes ist could look like:

from("direct:start")  // This is a java class and the message is a java object.
.choice()
.when(simple("${body.ID}=='A'")).to("bean:x")
.when(simple("${body.ID}=='B'")).to("bean:y")
.otherwise().to("bean:z")
.end();

While x, y, z are the spring ids...

Best regards - Claus

On 03.12.2010 09:59, nkrust wrote:
Hi,

The consumer is a java class and I'm passing a java VO to the producer(s)
depending on certain parameters in the VO.

from(endPoint)  // This is a java class and the message is a java object.
.choice()
.when(simple("${body.ID}=='A'")).to("serverX")
.when(simple("${body.ID}=='B'")).to("serverY")
.otherwise().to("serverZ")
.end();

I wanted to know how I can use a java class as consumer with VO as the
message. Also how the response which will again be a java object can be used
by the consumer.
I understand that camel is designed to work between a wide variety of
components and using from a java class is not really smart thing to do, but
I'm just doin a POC to see what all can be done.
Any insight appretiated.


--
claus straube
__________________________________________

phone    +49-89-38157419
mobile   +49-176-49673717
web      http://www.catify.com
office   6. floor, heßstr. 56, 80798 munich
__________________________________________

catify | claus straube, sebastian münz

Reply via email to