Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 64236 invoked from network); 2 Dec 2009 14:59:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Dec 2009 14:59:50 -0000 Received: (qmail 52778 invoked by uid 500); 2 Dec 2009 14:59:50 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 52741 invoked by uid 500); 2 Dec 2009 14:59:49 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 52731 invoked by uid 99); 2 Dec 2009 14:59:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 14:59:49 +0000 X-ASF-Spam-Status: No, hits=3.7 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cmoulliard@gmail.com designates 209.85.211.184 as permitted sender) Received: from [209.85.211.184] (HELO mail-yw0-f184.google.com) (209.85.211.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 14:59:36 +0000 Received: by ywh14 with SMTP id 14so212040ywh.20 for ; Wed, 02 Dec 2009 06:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=BuDOsKT921hFKg3qonbERq0qjGnx7SRf6L8GYnJoklQ=; b=GFsLOAYf6pxemei00CzCcVwZJs2K8xtpLzcujR7gexXyX9mdUIVj0T5xcTSWRCQbPY KbcIDJ5CHc2/K+4l5zxtUZTNFtEr7vtHm5QKZknENCq8RtoQZMyLIDDHeytlrWDWdFgT JBuzf6NFJhAgjkKyMlYVhK7bzxXklh2ARS5Qs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BcLtyBhet9LR6XF0FQK5m/apGlLqQOYARK1cjQI8hC5pIKZGxn/hucrjtIj6PxUmb+ WTlW8J4UMdO3872XmYFUXgV1w8Cozii89A2dE7qlFN0aZ5LJDT0w89WL8W4y2FxWxYBA KH9/j9FxCQJaUOEvkdDi8nv1pfX4HDbYJv6qQ= MIME-Version: 1.0 Received: by 10.101.129.8 with SMTP id g8mr91324ann.70.1259765952049; Wed, 02 Dec 2009 06:59:12 -0800 (PST) In-Reply-To: References: <4B13DC55.3020200@gmail.com> <4B13E442.3030204@gmail.com> <4B14825F.6060200@gmail.com> <4B14E485.2050106@gmail.com> Date: Wed, 2 Dec 2009 15:59:12 +0100 Message-ID: Subject: Re: CXF - camel CXF From: Charles Moulliard To: users@camel.apache.org Cc: Sergey Beryozkin , willem.jiang@gmail.com Content-Type: multipart/alternative; boundary=001636c595591271e40479c01ef3 X-Virus-Checked: Checked by ClamAV on apache.org --001636c595591271e40479c01ef3 Content-Type: text/plain; charset=ISO-8859-1 Forget my last remark. I have found the right way to dissociate the incoming call from the output Here is the camel-context config file As you can see, we don't need the Jaxrs:server bean and only cxfrs:bean:rsServer and code used (Thx for willem example CxfRsConsumerTest) where wde provide back the reply. In fact, this bean should become a factory where depending on the CxfConstants.OPERATION_NAME received we call the corresponding Service in our SOA environment public void processRequest(Exchange exchange) { Message inMessage = exchange.getIn(); // Get the operation name from in message String operationName = inMessage.getHeader(CxfConstants.OPERATION_NAME, String.class); // The parameter of the invocation is stored in the body of in message String id = (String) inMessage.getBody(Object[].class)[0]; if ("getIncident".equals(operationName)) { String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class); String uri = inMessage.getHeader(Exchange.HTTP_URI, String.class); if ("/cxf/camel-rest-example/reportservice/incidents/123/".equals(uri)) { Incident i = new Incident(); i.setIncidentId(Long.parseLong(id)); i.setFamilyName("Charles"); // We just put the response Object into the out message body exchange.getOut().setBody(i); } else { Response r = Response.status(404).entity("Can't found the customer with uri " + uri).build(); throw new WebApplicationException(r); } } } 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 Wed, Dec 2, 2009 at 12:11 PM, Charles Moulliard wrote: > @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 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) >>> >>> >>> >>> >>> webservice >>> >>> >> type="org.apache.camel.example.reportincident.InputReportIncident" /> >>> >>> >>> >>> >>> >>> >>> >>> >>> 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 >>> 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 >>>> >>>>>> 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 ? >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> 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 >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> serviceClass="org.apache.camel.example.reportincident.restful.ReportIncidentService" >>>>>>>>> /> >>>>>>>>> >>>>>>>>> >>>>>>>> /> >>>>>>>>> >>>>>>>>> >>>>>>>> xmlns="http://camel.apache.org/schema/osgi"> >>>>>>>>> >>>>>>>>> >>>>>>>>> // REST HTTP >>>>>>>>> Service >>>>>>>>> receiving the call from REST client and providing reply >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> // HTTP (internal >>>>>>>>> client) >>>>>>>>> who will generate HTTP reply using CXF - jaxrs:server component to >>>>>>>>> cxfrs:bean:rsServer endpoint >>>>>>>>> >>>>>>>>> >>>>>>>>> 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 >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>> >> > --001636c595591271e40479c01ef3--