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 8 17:10:40 2011, xuhb wrote:
It is not good to let your business logical aware the low level of camel 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) while
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"<willem.ji...@gmail.com>
To:<users@camel.apache.org>
Cc: "xuhb"<x...@tongtech.com>
Sent: Tuesday, November 08, 2011 4:02 PM
Subject: Re: Should camel extend the way of custom logical of camel route?
On Tue Nov 8 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 method which could be used to define a custom execution logic which
can invoke not only endpoint , but also other built in processors?
Here is a example:
there 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 return a
given person's info.
pseudocode expressed as following:
Person queryinfo(String name){
String[] addresses = readFromCfg();
for(String address : addresses){
person = new webservice(address).queryInfo(name);
if(person != null)
return person;
}
}
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 stop
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:
<route>
<...>
<setHeader name="addresses> <bean "readAddress"></setHeader>
<customExecution ref="customExecution ">
<recipientList> <header>singleAddress</header> </recipientList>
</customExecution>
</route>
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){
String[] addresses = ex.getIn().getHeader("addresses");
for(String address : addresses){
ex.getIn().setHeader("singleAddress", address);
getChildProcessor(0).process(ex);
if(containsPerson(ex.getOut().getBody())){
return;
}
}
}
----- Original Message -----
From: "Hadrian Zbarcea"<hzbar...@gmail.com>
To:<users@camel.apache.org>
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 also
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:
It seems the intercept is a extension of interceptor which enable user to
define intercept logic with camel description language;
Although camel provide predefined control logic: stop route& skip ; But if
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"<willem.ji...@gmail.com>
To:<users@camel.apache.org>
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 to define a custom logic ;
Here is a limitation: " only endpoint could be invoked in the custom execution
logic", so how about to support another mechanism which enable user to define custom
logical which could invoke processors defined 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 invoke the child processor
as they want;
2) change Pipeline , enable populate all child processors;
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang