Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF0C095F4 for ; Tue, 8 Nov 2011 15:49:05 +0000 (UTC) Received: (qmail 55129 invoked by uid 500); 8 Nov 2011 15:49:05 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 55097 invoked by uid 500); 8 Nov 2011 15:49:05 -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 55089 invoked by uid 99); 8 Nov 2011 15:49:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2011 15:49:05 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jesus.a.castillo@gmail.com designates 209.85.220.45 as permitted sender) Received: from [209.85.220.45] (HELO mail-dy0-f45.google.com) (209.85.220.45) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Nov 2011 15:49:01 +0000 Received: by dyj16 with SMTP id 16so29086dyj.32 for ; Tue, 08 Nov 2011 07:48:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=/W/1fOGFlEPYMYEp3pQEl1+XV08EDYTc4lyseGHvz5Q=; b=j21QhHnbvhwIoCNVXCxLbYebAoRDqlL6rQ/s3dxOLP4agvZJrMqNtGv+/JoJsdT+Ui W7FGwY43c6lm461H5TA5WyY2CjK2o2cjbdwb4zL2TUdNNhR2O1W1t7w2BT2JkQWSt2ws cm1PX8rWR4oAsSXziLWWpdxbBFtRJVop8lKzQ= MIME-Version: 1.0 Received: by 10.182.216.105 with SMTP id op9mr10179069obc.57.1320767319175; Tue, 08 Nov 2011 07:48:39 -0800 (PST) Received: by 10.182.17.226 with HTTP; Tue, 8 Nov 2011 07:48:38 -0800 (PST) In-Reply-To: <4EB908F0.9010602@gmail.com> References: <1320617620736-4969666.post@n5.nabble.com> <8CDAA4AB759C46EBA4ED028B52BC1175@user125cd2ff9a> <4EB7B67B.7010009@gmail.com> <4EB8B5D7.7060106@gmail.com> <3FBF94313F7F4D948BCB8592716EAC65@user125cd2ff9a> <4EB8E20F.4080509@gmail.com> <65EF651774C5452DA6B57D02D11B2D5D@user125cd2ff9a> <4EB908F0.9010602@gmail.com> Date: Tue, 8 Nov 2011 10:48:38 -0500 Message-ID: Subject: Re: Should camel extend the way of custom logical of camel route? From: =?UTF-8?Q?Jes=C3=BAs_Castillo?= To: users@camel.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In general, I would avoid writing business logic by using interceptors and all this low level Camel API. In your example, you can either use the Recipient List with a customized Aggregation strategy that keeps the Exchange that reports the person's info or use the Dynamic Router and stop the web service querying when the person's info is found. With the recipient list, however, you always query all the web services eve= n if you get your reply already. Rgds, Jesus. 2011/11/8 Willem Jiang : > You can pass the header to be bean by adding the annotation @header[1]. > [1]http://camel.apache.org/bean-binding.html > > > On Tue Nov =C2=A08 17:10:40 2011, xuhb wrote: >>> >>> It is not good to let your business logical aware the low level of =C2= =A0camel >>> API. >> >> Yes, it's bad. if there are other ways, we will prefer to it; >>> >>> It could be more handy if you let camel to call a customer bean. >> >> ...unfortunately, I still haven't thought out a way to resolve the >> example(query user-info example , which illustrated in previous mail) wh= ile >> using injected endpoint with bean; The diffcult is how to deal with the >> dynamic address in bean. >> >>> Then you can do what you want with it :) >> >> >> ----- Original Message ----- >> From: "Willem Jiang" >> To: >> Cc: "xuhb" >> Sent: Tuesday, November 08, 2011 4:02 PM >> Subject: Re: Should camel extend the way of custom logical of camel rout= e? >> >> >>> On Tue Nov =C2=A08 14:37:59 2011, xuhb wrote: >>>> >>>> Thanks Hadrian Zbarcea: >>>> >>>> ..... it seems the discuss has stray away from my original question. >>>> the original question is : >>>> >>>> when execution logic of route cannot be expressed by camel's built in >>>> MEP. >>>> Is there =C2=A0method which could be used to define a =C2=A0custom exe= cution logic >>>> which can invoke not only endpoint , but also other built in processor= s? >>>> >>>> Here is a =C2=A0example: >>>> =C2=A0 =C2=A0 =C2=A0there are some web services which could be used to= query a person's >>>> infomation; we need try them one by one, until one webservice has retu= rn a >>>> given person's info. >>>> pseudocode expressed as following: >>>> >>>> Person queryinfo(String name){ >>>> =C2=A0 =C2=A0 =C2=A0String[] addresses =3D readFromCfg(); >>>> =C2=A0 =C2=A0 =C2=A0for(String address : addresses){ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0person =3D new webservice(address).q= ueryInfo(name); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if(person !=3D null) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return person; >>>> =C2=A0 =C2=A0 =C2=A0} >>>> } >>>> >>>> But using camel, I dont know how to write a route do same things; >>>> Although recipeint list could do likeness. but I dont know how to =C2= =A0stop >>>> execution when a person infomation is got. (although I could raise a >>>> exception to force receipent list stop, but it's not reason-able); >>>> >>>> So I am wonderring if camel could provide some mechanis which enable I >>>> write a custom logic to schedule execution of camel processor. it may = looks >>>> like: >>>> >>>> >>>> =C2=A0 =C2=A0 =C2=A0<...> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>> =C2=A0 =C2=A0 =C2=A0 >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
singl= eAddress
>>>>
>>>> =C2=A0 =C2=A0 =C2=A0
>>>>
>>>> >>> It is not good to let your business logical aware the low level of >>> camel API. >>> It could be more handy if you let camel to call a customer bean. >>> Then you can do what you want with it :) >>> >>>> class customExecution { >>>> void process(Exchange ex){ >>>> =C2=A0 =C2=A0String[] addresses =3D ex.getIn().getHeader("addresses"); >>>> =C2=A0 =C2=A0for(String address : addresses){ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0ex.getIn().setHeader("singleAddress", addre= ss); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0getChildProcessor(0).process(ex); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0if(containsPerson(ex.getOut().getBody())){ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return; >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>> =C2=A0 =C2=A0} >>>> } >>>> ----- Original Message ----- >>>> From: "Hadrian Zbarcea" >>>> To: >>>> Sent: Tuesday, November 08, 2011 12:53 PM >>>> Subject: Re: Should camel extend the way of custom logical of camel >>>> route? >>>> >>>> >>>>> Sure you can, there is also a loop [1] you could use for repetitive >>>>> invocations. You can also define your own interceptor, which could al= so >>>>> use a builder if you want to configure any kind of custom logic you >>>>> might dream of. There's only so much we can provide out of the box. >>>>> >>>>> Cheers, >>>>> Hadrian >>>>> >>>>> [1] http://camel.apache.org/loop.html >>>>> >>>>> >>>>> >>>>> On 11/07/2011 10:09 PM, xuhb wrote: >>>>>> >>>>>> Thanks Willem: >>>>>> =C2=A0 =C2=A0 =C2=A0It seems the intercept is a extension of interce= ptor which enable >>>>>> user to define intercept logic with camel description language; >>>>>> Although camel provide predefined control logic: stop route& =C2=A0 = =C2=A0skip ; >>>>>> =C2=A0But =C2=A0if we need other executing logic, could I define it? >>>>>> >>>>>> for example: could I define how many times the processor will be >>>>>> executed with intercept? >>>>>> >>>>>> >>>>>> ----- Original Message ----- >>>>>> From: "Willem Jiang" >>>>>> To: >>>>>> Sent: Monday, November 07, 2011 6:44 PM >>>>>> Subject: Re: Should camel extend the way of custom logical of camel >>>>>> route? >>>>>> >>>>>> >>>>>>> I think you can do the same thing with Intercept[1]. >>>>>>> >>>>>>> [1]http://camel.apache.org/intercept.html >>>>>>> >>>>>>> On 11/7/11 1:51 PM, xuhb wrote: >>>>>>>> >>>>>>>> When the application's execution logic is sophisticate , we can >>>>>>>> using endpoint and java bean =C2=A0to define a custom logic ; >>>>>>>> >>>>>>>> Here is a limitation: " only endpoint could be invoked in the cust= om >>>>>>>> execution logic", so how about to support another mechanism which = enable >>>>>>>> user to define custom logical which could invoke processors define= d in route >>>>>>>> (also endpoint can be invoked)? >>>>>>>> >>>>>>>> Is this worth to do for camel? >>>>>>>> >>>>>>>> Following is a proto-type (which is not good, because the >>>>>>>> implementation way violate the natural usage of camel's component)= ; >>>>>>>> >>>>>>>> 1)extending a policy ,the policy enable user to retrieve the child >>>>>>>> processor with index or processor id; and the end-user could invok= e the >>>>>>>> child processor as they want; >>>>>>>> 2) change Pipeline , enable populate all child processors; >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Willem >>>>>>> ---------------------------------- >>>>>>> FuseSource >>>>>>> Web: http://www.fusesource.com >>>>>>> Blog: =C2=A0 =C2=A0http://willemjiang.blogspot.com (English) >>>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0http://jnn.javaeye.com (Ch= inese) >>>>>>> Twitter: willemjiang >>>>>>> Weibo: willemjiang >>>>>>> >>>>> >>> >>> >>> >>> -- >>> Willem >>> ---------------------------------- >>> FuseSource >>> Web: http://www.fusesource.com >>> Blog: =C2=A0 =C2=A0http://willemjiang.blogspot.com (English) >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://jnn.javaeye.com (Chinese) >>> Twitter: willemjiang >>> Weibo: willemjiang >>> >> > > > > > -- > Willem > ---------------------------------- > FuseSource > Web: http://www.fusesource.com > Blog: =C2=A0 =C2=A0http://willemjiang.blogspot.com (English) > =C2=A0 =C2=A0 =C2=A0 =C2=A0http://jnn.javaeye.com (Chinese) > Twitter: willemjiang Weibo: willemjiang >