The idea is that UserService#getUserById will call to the external endpoint to actually get a user ? If yes: JAX-RS can help there, it deals with replacing the template variables pretty well, can be managed with the fluent API but also with proxies. Example, you'd initialize a client with "http://host:port/api/user/id/{id}"; and the JAX-RS client runtime will replace all variables with actual values

Cheers, Sergey
On 02/08/13 07:56, andreyrikunov wrote:
Say I would like to exploit Camel as a client to a RESTful web service. But
not sure Camel is good enough for such kind of job. I also want to use http4
or ahc component, not cxf.

In general I need only two kinds of routes:

- from Bean -> marshall to Json -> to Ahc with static URI -> unmarshall from
Json -> to Bean.
Example of static uri: ahc:http://host/api/user/create

- from Bean -> marshall to Json -> to Ahc with dynamic URI -> unmarshall
from Json -> to Bean.
Example of dynamic uri: ahc:http://host/api/user/id/1

I imagine to have a service class to fire such a routes in a manner like:

UserService {

     @Autowired
     protected CamelContext restApiCamelContext;

     public UserCreateResponse createUser (UserModel user) {
         ... Camel's magick which starts create user route ...
     }

     public UserModel getUserById (Long id) {
         ... the id must be placed somehow into endpoint uri:
http://host:port/api/user/id/${id} ...
         ... Camel's magick which get user by id ...
     }
}

The UserService is supposed to be used in Spring MVC controllers.

So, is it possible to implement such a UserService based on Camel's
capabilities? If yes, then will it work good under high pressure of tons of
user requests comming to a spring controller? Will it work fine with near
hundred of different uris?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Can-Camel-be-used-as-RESTful-API-webservice-client-tp5736676.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to