1

I have a restful webservice build on CXF framework. the requirement is that when someone hits this server i have to fetch some data from content providers like google, bing etc according to the parameters received and have to give back the same to the client. now calling service provider and getting its result is to be done using Camel Framework. i have identified that using simple routes from("direct:start").to("http://google.com).bean(ffoo|bar) can let me talk to the service provider and do whatever i want with the result. but the problem is what should be in the place of "direct:start" so that this route starts from my service method which is being hit by the client. i read a bit about POJO producing but i could not understand how does it works and whether it will solve my problem.

Also i have a query .. that in this syntax.. from().to() ... to is the consmer and from is the producer or vice versa?? because in my logs it says route is consuming from the direct:start... Would prefer a spring configuration type of answer

Thanks

Sikorski
  • 2,653
  • 3
  • 25
  • 46
  • To make sure I understand - you're using CXF *without* camel, and when someone hits the server, your CXF code creates a producer and sends a message to 'direct:start' ? – Roy Truelove Apr 18 '12 at 15:04
  • yes cxf is independent of camel. now when somebody hits my server, i need to connect to Google using camel. is there some camel component which can directly take my server in the from syntax. I mean that instead of (direct:start) it may be some (server:foobar). – Sikorski Apr 19 '12 at 05:29

2 Answers2

1

Yes, Camel can expose REST services and route those requests downstream.

There are a few options you can use. Sounds like the first option will be the least painful:

EDIT - to reply to the comments

All of the components above can be used on the server side to expose the server as a REST-based web service. In Camel-speak, that means that means that you're using the component as a consumer, since it consumes messages from the outside.

For more information about Producers vs Consumers, I wouldn't be able to do any better explaining it than the author himself.

Community
  • 1
  • 1
Roy Truelove
  • 22,016
  • 18
  • 111
  • 153
  • also please clarify this : that in this syntax.. from().to() ... to is the consmer and from is the producer or vice versa?? because in my logs it says route is consuming from the direct:start – Sikorski Apr 19 '12 at 12:15
  • CXFRS component, do you mean that i should expose my rest webservice using this ?? or should i use only its client side ? i am bit confused. – Sikorski Apr 19 '12 at 12:21
  • Edited the message a bit, hope it helps! – Roy Truelove Apr 19 '12 at 14:06
0

Initially i implemented cxfrs component for my webservice (inspired by Roy Truelove's answer) but that lead to other complications. so now using direct:start component for starting the route .. my config looks like this:

<camel:route>
<camel:from uri="direct:start" />
<camel:process ref="customInProcessor" />
<camel:to uri="http://localhost:8080/DummyGoogleProject/search" />
<camel:to uri="bean:googleResponseHandler" />
</camel:route>
</camel:camelContext>

customInProcessor does some processing like modifying CamelHttpUri , Path , Query etc (without this there were some problems in route execution) I am injecting exchanges in "direct:start" endpoint via ProducerTemplate from my POJOs (POJO producing)

Community
  • 1
  • 1
Sikorski
  • 2,653
  • 3
  • 25
  • 46