camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <cmoulli...@gmail.com>
Subject Re: CXF - camel CXF
Date Wed, 02 Dec 2009 11:11:48 GMT
@Willem,

An elegant alternative approach could be that the thread running the method
called in the REST service :

    @GET
    @Path("/incidents/{id}/")
    public Incident getIncident(@PathParam("id") String id) {
        long idNumber = Long.parseLong(id);
        Incident i = incidents.get(idNumber);
        return i;
    }

is suspended and resumed when we receive through Camel route what the client
is expected to receive as reply. This could be achieved if we add a new
annotation @ProcessStatus to inform camel endpoint or CXF that we wait
exchange return from Camel route (where we call a POJO in charge by example
to make a DataBase request) before to provide back the reply to the RESTfull
client.

Regards,

Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com
twitter : http://twitter.com/cmoulliard
Linkedlin : http://www.linkedin.com/in/charlesmoulliard

Apache Camel Group :
http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm


On Tue, Dec 1, 2009 at 10:40 AM, Willem Jiang <willem.jiang@gmail.com>wrote:

> It should work, but you need to some additional work.
>
> As cxfrs producer uses the HttpClient API by default, it is different with
> the camel-cxf's client API, so you need to find some way to deal with the
> REST response object issue which you shows in CAMEL-2239.
>
> In camel-example-cxf , we have an example[1] to show how to provides a
> service which support soap request and REST at same time.
>
> [1]
> https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-cxf/src/main/java/org/apache/camel/example/cxf/jaxrs/CamelRouterBuilder.java
>
>
> Willem
>
> Charles Moulliard wrote:
>
>> Hi Willem,
>>
>> To come back to REST implementation between Camel - CXF, can you tell me
>> why
>> we cannot do the same thing (RESTfull services) that we can do for CXF web
>> service ?
>>
>> Here is the camel route that I use in my camel osgi tutorial (part2)
>>
>>        <camel:route>
>>            <camel:from uri="cxf:bean:reportIncident" />
>>            <camel:setHeader headerName="origin">
>>                <camel:constant>webservice</camel:constant>
>>            </camel:setHeader>
>>            <camel:convertBodyTo
>> type="org.apache.camel.example.reportincident.InputReportIncident" />
>>            <camel:to uri="bean:webservice" />
>>            <camel:inOnly uri="queuingservice:queue:in" />
>>            <camel:transform>
>>                <camel:method bean="feedback" method="setOk" />
>>            </camel:transform>
>>
>>        </camel:route>
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>> twitter : http://twitter.com/cmoulliard
>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>
>> Apache Camel Group :
>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>
>>
>> On Tue, Dec 1, 2009 at 3:41 AM, Willem Jiang <willem.jiang@gmail.com>
>> wrote:
>>
>>  Hi Charles,
>>>
>>> It really dependents on your use case.
>>>
>>> Here is an user case, if have bunch of back end (jaxrs:server) services,
>>> and you want to do a content based routing, you can user setup a camel
>>> cxfrsServer and let the client access this server. Then camel route will
>>>  take care rest of things :)
>>>
>>>
>>> Willem
>>>
>>> Charles Moulliard wrote:
>>>
>>>  If it makes no sense to use rsServer and rsClient both together in a
>>>> camel
>>>> route, what is the advantage to use a camel cxfrsServer endpoint over
>>>> the
>>>> jaxrs:server endpoint ?
>>>>
>>>> Regards,
>>>>
>>>> Charles Moulliard
>>>> Senior Enterprise Architect
>>>> Apache Camel Committer
>>>>
>>>> *****************************
>>>> blog : http://cmoulliard.blogspot.com
>>>> twitter : http://twitter.com/cmoulliard
>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>>>
>>>> Apache Camel Group :
>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>>>
>>>>
>>>> On Mon, Nov 30, 2009 at 4:26 PM, Willem Jiang <willem.jiang@gmail.com
>>>>
>>>>> wrote:
>>>>>
>>>>  Oh, this test case just show how camel-cxfrs consumer and camel-cxfrs
>>>>
>>>>> producer work together.
>>>>>
>>>>> It is not easy to write a bunch of tests to verify a camel-cxfrs
>>>>> consumer
>>>>> can response different request in a short time, so why not we create
 a
>>>>> camel-cxfrs route in Camel to test the consumer and producer at the
>>>>> same
>>>>> time.
>>>>>
>>>>> Willem
>>>>>
>>>>>
>>>>> Charles Moulliard wrote:
>>>>>
>>>>>  If you recommend to call directly the service from the POJO where we
>>>>>
>>>>>> have
>>>>>> added REST annotation, what is the purpose of this route presented
as
>>>>>> an
>>>>>> example in camel-cxf test if the cxf:rsServer:bean:server endpoint
can
>>>>>> directly answer to a GET/PUT,POST, ... call ?
>>>>>>
>>>>>> <route>
>>>>>> <cxf:rsServer:bean:server/>
>>>>>> <cxf:rsClient:bean:client/>
>>>>>> </route>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Charles Moulliard
>>>>>> Senior Enterprise Architect
>>>>>> Apache Camel Committer
>>>>>>
>>>>>> *****************************
>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>> twitter : http://twitter.com/cmoulliard
>>>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>>>>>
>>>>>> Apache Camel Group :
>>>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 30, 2009 at 3:53 PM, Willem Jiang <willem.jiang@gmail.com
>>>>>>
>>>>>>  wrote:
>>>>>>>
>>>>>>>   Hi Charles,
>>>>>>
>>>>>>  You don't need to use the camel cxfrs route all the time, if you
have
>>>>>>> to
>>>>>>>  retrieve the DB for the REST request.
>>>>>>>
>>>>>>> You just need to define a POJO with annotation, and use OR mapping
>>>>>>> framework to implement retrieve or update the data for your service.
>>>>>>> You
>>>>>>> don't need to let camel be involved ;)
>>>>>>>
>>>>>>> Willem
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Charles Moulliard wrote:
>>>>>>>
>>>>>>>  Hi,
>>>>>>>
>>>>>>>  If camel is used in combination with CXF to handle REST services,
>>>>>>>> How
>>>>>>>> must
>>>>>>>> be designed the POJOs managing the REST services ?
>>>>>>>>
>>>>>>>> eg. camel spring config
>>>>>>>>
>>>>>>>>  <cxf:rsServer id="rsServer" address="/camel-rest-example/"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService"
>>>>>>>> />
>>>>>>>>
>>>>>>>>  <cxf:rsClient id="rsClient" address="
>>>>>>>> http://localhost:8181/cxf/http/
>>>>>>>> "
>>>>>>>> />
>>>>>>>>
>>>>>>>>  <camel:camelContext trace="true"
>>>>>>>>     xmlns="http://camel.apache.org/schema/osgi">
>>>>>>>>
>>>>>>>>     <camel:route>
>>>>>>>>         <camel:from uri="cxfrs:bean:rsServer" /> //
REST HTTP
>>>>>>>> Service
>>>>>>>> receiving the call from REST client and providing reply
>>>>>>>>         <camel:bean ref="service" method="getCustomer"
/>
>>>>>>>>         <camel:to uri="activemq:queue:IN"/>
>>>>>>>>     </camel:route>
>>>>>>>>
>>>>>>>>    <camel:route>
>>>>>>>>         <camel:from uri="activemq:queue:IN" />
>>>>>>>>         <camel:to uri="cxfrs:bean:rsClient" /> // HTTP
(internal
>>>>>>>> client)
>>>>>>>> who will generate HTTP reply using CXF - jaxrs:server component
to
>>>>>>>> cxfrs:bean:rsServer endpoint
>>>>>>>>     </camel:route>
>>>>>>>>
>>>>>>>> Do we have to create two POJOs (one for the request and the
other
>>>>>>>> for
>>>>>>>> the
>>>>>>>> reply ?
>>>>>>>> If this is the case, how the method must be defined to provide
the
>>>>>>>> REST
>>>>>>>> info
>>>>>>>> (request, parameters, ...) to the camel endpoint (= camel
bean) who
>>>>>>>> will
>>>>>>>> be
>>>>>>>> in charge to retrieve by example info from DB ? idem but
for the
>>>>>>>> method
>>>>>>>> who
>>>>>>>> will be send back the reply to the client calling the REST
service ?
>>>>>>>>
>>>>>>>> ex : Request
>>>>>>>>
>>>>>>>>  @GET
>>>>>>>>  @Path("/customers/{id}/")
>>>>>>>>  public String getCustomer(@PathParam("id") String id) {
>>>>>>>>     return id;
>>>>>>>>  }
>>>>>>>>
>>>>>>>> ex: reply
>>>>>>>>
>>>>>>>>  @GET
>>>>>>>>  @Path("/customers/{id}/")
>>>>>>>>  public Customer getCustomer(Customer customer) {
>>>>>>>>     return customer;
>>>>>>>>  }
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> Charles Moulliard
>>>>>>>> Senior Enterprise Architect
>>>>>>>> Apache Camel Committer
>>>>>>>>
>>>>>>>> *****************************
>>>>>>>> blog : http://cmoulliard.blogspot.com
>>>>>>>> twitter : http://twitter.com/cmoulliard
>>>>>>>> Linkedlin : http://www.linkedin.com/in/charlesmoulliard
>>>>>>>>
>>>>>>>> Apache Camel Group :
>>>>>>>> http://www.linkedin.com/groups?home=&gid=2447439&trk=anet_ug_hm
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>
>

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