You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ext2 <xu...@tongtech.com> on 2010/04/22 07:35:00 UTC

does camel support custom policy for processor level ?

Hi:
	Camel policy is very useful to define some custom wrapper features;
But in camel 2.2 , it seems the policy only apply on the whole route; And it
cannot define a policy on a special processor, is this true?
	And does camel 2.x support some mechanism to support define custom
policy for specified processor(not the whole route)?



Re: does camel support custom policy for processor level ?

Posted by Willem Jiang <wi...@gmail.com>.
ext2 wrote:
> Thanks Willem:
> 
> I got it; and using this feature I could define custom transaction range in
> a single route(need not separate them in different route just for
> transaction purpose);
> 
> 
I'm afraid you cannot configure the transaction per process, as Camel 
transaction is based on Spring, and it uses thread location to hold the 
transaction information. You may need to do something yourself to 
implement the feature.

> 
> 
>>> Willem wrote:
>>> No, you can apply the police per processor.
>>> The new added camel-spring-security is based on this camel policy feature.
> 
> how to configure such policy using spring? Or just dsl?
> 
> Willem
> 
> ext2 wrote:
>> Hi:
>> 	Camel policy is very useful to define some custom wrapper features;
>> But in camel 2.2 , it seems the policy only apply on the whole route; And
> it
>> cannot define a policy on a special processor, is this true?
>> 	And does camel 2.x support some mechanism to support define custom
>> policy for specified processor(not the whole route)?
>>
>>
>>
> 
> 
> 
> 
> 
> 


Re: Can I configure sync or asynchronous for individual processor in spring?

Posted by Willem Jiang <wi...@gmail.com>.
There is a sync option which you can use the let the component to be 
sync or async.

For the processor, if it does not implement AsyncProcessor interface, it 
will be ran synchronously.

You can find more information the component which support the async 
option here[1].

[1]http://camel.apache.org/asynchronous-routing-engine.html

 From Camel 2.4.0, we did some work to make the camel asyn
On 10/13/10 12:45 PM, ext2 wrote:
> Can I configure sync or asynchronous for individual processor in spring?
>    If so , I could separate the CPU-cost actions and IO-Cost  actions in
> different thread more clearly;
>
>
>
>


-- 
Willem
----------------------------------
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang

Can I configure sync or asynchronous for individual processor in spring?

Posted by ext2 <xu...@tongtech.com>.
Can I configure sync or asynchronous for individual processor in spring?
  If so , I could separate the CPU-cost actions and IO-Cost  actions in
different thread more clearly;




Re: Is this a bug of try-catch or transaction?

Posted by ext2 <xu...@tongtech.com>.
Thanks willem:

It seems that the onException has a little different difference to
try-catch;

That's : 
try-catch could recover the exception and continue to execute next processor
in pipeline
But on-Exception always stop execute when exception occurs in pipeline

I am not very sure about this(But according  the camel 2.2's source code ,it
does so, and I have tried a simple sample to prove this); if it does only
works as such means, the onException cannot replace try-catch completely;


Willem wrote:

>How about using the onExeption[1] ?
>It works within the ErrorHandler, and it can do the same thing as 
>doTry... doCatch does.

[1]http://camel.apache.org/exception-clause.html

Willem

ext2 wrote:
> Thanks Claus Ibsen:
> 
> If we just consider this example, move policy before doTry could resolve
it; but If we  consider another situation:
> 	<doTry>
> 		..some other operation ..
> 		<policy ref="...>
> 			transaction operations
> 		</policy>
> 		<docatch>
> 		</docatch>
> 	</dotry>
> 
> At this time, I cannot move policy to <doTry/> easily; and also, if
transaction operations  raise exception, the doCatch cannot catch it;
> 
> 
> Claus Ibsen wrote:
>> Move the <policy> before the <doTry>
> 
> 
>> On Thu, Apr 22, 2010 at 9:08 AM, ext2 <xu...@tongtech.com> wrote:
>>
>> Hi:
>>
>> The camel's transaction required the transacted-error-handler, but
try-catch
>> required no-error-handler. They will conflict; following is a sample that
>> the try-catch cannot works while using transaction. but I am not sure if
>> this is bug or just a camel's limit?
>>
>> For example, the following route :
>>
>> <doTry>
>>        <policy ref="PROPAGATION_REQUIRED">
>>        <pipeline>
>>     <to uri="ibatis:table.add?statementType=Insert"/>
>>     <bean ref="errorbean" method="raiseError"/>
>>     </pipeline>
>>     </policy>
>> <doCatch>
>> <exception>java.lang.Exception</exception>
>> <bean ref="mybean" method="foo"/>
>> </doCatch>
>>
>> As for normal understanding: the errorbean(just after ibatis) raise
error,
>> so the pipeline will marked as rollback status, but the exception is
still
>> exist, and the catch clause will be execute.And in camel, doCatch cannot
be
>> execute;
>>
>>
>>
> 
> 
> 




Re: 答复: Is this a bug of try-catch or transaction?

Posted by Willem Jiang <wi...@gmail.com>.
How about using the onExeption[1] ?
It works within the ErrorHandler, and it can do the same thing as 
doTry... doCatch does.

[1]http://camel.apache.org/exception-clause.html

Willem

ext2 wrote:
> Thanks Claus Ibsen:
> 
> If we just consider this example, move policy before doTry could resolve it; but If we  consider another situation:
> 	<doTry>
> 		..some other operation ..
> 		<policy ref="...>
> 			transaction operations
> 		</policy>
> 		<docatch>
> 		</docatch>
> 	</dotry>
> 
> At this time, I cannot move policy to <doTry/> easily; and also, if transaction operations  raise exception, the doCatch cannot catch it;
> 
> 
> Claus Ibsen wrote:
>> Move the <policy> before the <doTry>
> 
> 
>> On Thu, Apr 22, 2010 at 9:08 AM, ext2 <xu...@tongtech.com> wrote:
>>
>> Hi:
>>
>> The camel's transaction required the transacted-error-handler, but try-catch
>> required no-error-handler. They will conflict; following is a sample that
>> the try-catch cannot works while using transaction. but I am not sure if
>> this is bug or just a camel's limit?
>>
>> For example, the following route :
>>
>> <doTry>
>>        <policy ref="PROPAGATION_REQUIRED">
>>        <pipeline>
>>     <to uri="ibatis:table.add?statementType=Insert"/>
>>     <bean ref="errorbean" method="raiseError"/>
>>     </pipeline>
>>     </policy>
>> <doCatch>
>> <exception>java.lang.Exception</exception>
>> <bean ref="mybean" method="foo"/>
>> </doCatch>
>>
>> As for normal understanding: the errorbean(just after ibatis) raise error,
>> so the pipeline will marked as rollback status, but the exception is still
>> exist, and the catch clause will be execute.And in camel, doCatch cannot be
>> execute;
>>
>>
>>
> 
> 
> 


答复: Is this a bug of try-catch or transaction?

Posted by ext2 <xu...@tongtech.com>.
Thanks Claus Ibsen:

If we just consider this example, move policy before doTry could resolve it; but If we  consider another situation:
	<doTry>
		..some other operation ..
		<policy ref="...>
			transaction operations
		</policy>
		<docatch>
		</docatch>
	</dotry>

At this time, I cannot move policy to <doTry/> easily; and also, if transaction operations  raise exception, the doCatch cannot catch it;


Claus Ibsen wrote:
>Move the <policy> before the <doTry>


>On Thu, Apr 22, 2010 at 9:08 AM, ext2 <xu...@tongtech.com> wrote:
>
> Hi:
>
> The camel's transaction required the transacted-error-handler, but try-catch
> required no-error-handler. They will conflict; following is a sample that
> the try-catch cannot works while using transaction. but I am not sure if
> this is bug or just a camel's limit?
>
> For example, the following route :
>
> <doTry>
>        <policy ref="PROPAGATION_REQUIRED">
>        <pipeline>
>     <to uri="ibatis:table.add?statementType=Insert"/>
>     <bean ref="errorbean" method="raiseError"/>
>     </pipeline>
>     </policy>
> <doCatch>
> <exception>java.lang.Exception</exception>
> <bean ref="mybean" method="foo"/>
> </doCatch>
>
> As for normal understanding: the errorbean(just after ibatis) raise error,
> so the pipeline will marked as rollback status, but the exception is still
> exist, and the catch clause will be execute.And in camel, doCatch cannot be
> execute;
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus



Re: Is this a bug of try-catch or transaction?

Posted by Claus Ibsen <cl...@gmail.com>.
Move the <policy> before the <doTry>


On Thu, Apr 22, 2010 at 9:08 AM, ext2 <xu...@tongtech.com> wrote:
>
> Hi:
>
> The camel's transaction required the transacted-error-handler, but try-catch
> required no-error-handler. They will conflict; following is a sample that
> the try-catch cannot works while using transaction. but I am not sure if
> this is bug or just a camel's limit?
>
> For example, the following route :
>
> <doTry>
>        <policy ref="PROPAGATION_REQUIRED">
>        <pipeline>
>     <to uri="ibatis:table.add?statementType=Insert"/>
>     <bean ref="errorbean" method="raiseError"/>
>     </pipeline>
>     </policy>
> <doCatch>
> <exception>java.lang.Exception</exception>
> <bean ref="mybean" method="foo"/>
> </doCatch>
>
> As for normal understanding: the errorbean(just after ibatis) raise error,
> so the pipeline will marked as rollback status, but the exception is still
> exist, and the catch clause will be execute.And in camel, doCatch cannot be
> execute;
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Is this a bug of try-catch or transaction?

Posted by ext2 <xu...@tongtech.com>.
Hi:

The camel's transaction required the transacted-error-handler, but try-catch
required no-error-handler. They will conflict; following is a sample that
the try-catch cannot works while using transaction. but I am not sure if
this is bug or just a camel's limit?

For example, the following route :

<doTry>
	<policy ref="PROPAGATION_REQUIRED">
	<pipeline>
     <to uri="ibatis:table.add?statementType=Insert"/>
     <bean ref="errorbean" method="raiseError"/> 
     </pipeline>
     </policy>
<doCatch>
<exception>java.lang.Exception</exception>
<bean ref="mybean" method="foo"/>
</doCatch>

As for normal understanding: the errorbean(just after ibatis) raise error,
so the pipeline will marked as rollback status, but the exception is still
exist, and the catch clause will be execute.And in camel, doCatch cannot be
execute;



Re: does camel support custom policy for processor level ?

Posted by Willem Jiang <wi...@gmail.com>.
ext2 wrote:
> Thanks Willem:
> 
> I got it; and using this feature I could define custom transaction range in
> a single route(need not separate them in different route just for
> transaction purpose);
> 
> 
I just checked the code, the SpringTransactionPolicy is setting a new 
TransactionErrorHandler per route , not just wrapping the processor, so 
it works per route. If you want to change this , you need to write your 
owner TransactionPolicy.

> 
> 
>>> Willem wrote:
>>> No, you can apply the police per processor.
>>> The new added camel-spring-security is based on this camel policy feature.
> 
> how to configure such policy using spring? Or just dsl?
> 
> Willem
> 
> ext2 wrote:
>> Hi:
>> 	Camel policy is very useful to define some custom wrapper features;
>> But in camel 2.2 , it seems the policy only apply on the whole route; And
> it
>> cannot define a policy on a special processor, is this true?
>> 	And does camel 2.x support some mechanism to support define custom
>> policy for specified processor(not the whole route)?
>>
>>
>>
> 
> 
> 
> 
> 
> 


Re: does camel support custom policy for processor level ?

Posted by ext2 <xu...@tongtech.com>.
Thanks Willem:

I got it; and using this feature I could define custom transaction range in
a single route(need not separate them in different route just for
transaction purpose);




>>Willem wrote:
>>No, you can apply the police per processor.
>>The new added camel-spring-security is based on this camel policy feature.

how to configure such policy using spring? Or just dsl?

Willem

ext2 wrote:
> Hi:
> 	Camel policy is very useful to define some custom wrapper features;
> But in camel 2.2 , it seems the policy only apply on the whole route; And
it
> cannot define a policy on a special processor, is this true?
> 	And does camel 2.x support some mechanism to support define custom
> policy for specified processor(not the whole route)?
> 
> 
> 






Re: does camel support custom policy for processor level ?

Posted by Willem Jiang <wi...@gmail.com>.
ext2 wrote:
> Willem wrote:
>>> No, you can apply the police per processor.
>>> The new added camel-spring-security is based on this camel policy feature.
> 
> how to configure such policy using spring? Or just dsl?
> 
Please check out the camel-spring-security example[1].

<policy ref=xxx> or .policy("xxx").


[1]https://cwiki.apache.org/confluence/display/CAMEL/Spring+Security+Example

> Willem
> 
> ext2 wrote:
>> Hi:
>> 	Camel policy is very useful to define some custom wrapper features;
>> But in camel 2.2 , it seems the policy only apply on the whole route; And
> it
>> cannot define a policy on a special processor, is this true?
>> 	And does camel 2.x support some mechanism to support define custom
>> policy for specified processor(not the whole route)?
>>
>>
>>
> 
> 
> 
> 


Re: does camel support custom policy for processor level ?

Posted by ext2 <xu...@tongtech.com>.
Willem wrote:
>>No, you can apply the police per processor.
>>The new added camel-spring-security is based on this camel policy feature.

how to configure such policy using spring? Or just dsl?

Willem

ext2 wrote:
> Hi:
> 	Camel policy is very useful to define some custom wrapper features;
> But in camel 2.2 , it seems the policy only apply on the whole route; And
it
> cannot define a policy on a special processor, is this true?
> 	And does camel 2.x support some mechanism to support define custom
> policy for specified processor(not the whole route)?
> 
> 
> 




Re: does camel support custom policy for processor level ?

Posted by Willem Jiang <wi...@gmail.com>.
No, you can apply the police per processor.
The new added camel-spring-security is based on this camel policy feature.

Willem

ext2 wrote:
> Hi:
> 	Camel policy is very useful to define some custom wrapper features;
> But in camel 2.2 , it seems the policy only apply on the whole route; And it
> cannot define a policy on a special processor, is this true?
> 	And does camel 2.x support some mechanism to support define custom
> policy for specified processor(not the whole route)?
> 
> 
>