[ 
https://issues.apache.org/activemq/browse/SM-1702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=47619#action_47619
 ] 

Freeman Fang commented on SM-1702:
----------------------------------

Hi Guillaume,

You are correct, the delivery channel is thread safe and no need to add 
synchronized block here.

I try to explain more about my scenario.
Actually I try to fix a cocurrent issue.
The flow is
multiple external client ===> cxf bc consumer(sendSync) ====> cxf bc se
The error is that cxf bc consumer get response message with status ERROR but 
getFault() == null if multiple external invocation  come in at same time
As we chat yesterday, you said this could be caused by the timeout of sendSync, 
yes, I verify that is the case.
Moreover, after debug into the code, I found that the timeout is caused by cxf 
se  used up its default thread (the default corePoolSize is 4 for cxf se 
component), so if there are more than 4  sync invocation coming to cxf se, cxf 
se will hang on sendSync(where try to send back response, but there is no more 
thread in cxf se for doRouting since all 4 threads is block on waiting, and the 
task for Flow.doRouting() is in the queue now, that means the sendSync() of cxf 
se blocked for wait() but no thread to notify them), hence cause the timeout on 
cxf bc side.



The solution is 
1. add synchronous="false" for cxf bc consumer endpoint, so that the cxf bc and 
cxf se will use send() (non thread block),  the asynchronized invocation is 
more suitable for the cocurrency.
2. when use synchronous way, ensure that the incoming messsage for cxf se isn't 
more than the corePoolSize, so that there is still thread left for doRouting, 
we can 
configure the jetty thread pool in cxf bc consumer and executorFactory in cxf 
se to guarantee it (the jetty thread pool size for cxf bc consumer should less 
then the corePoolSize for cxf se).
I will remove the lock for DeliveryChannel and modify test to show how to 
configure cxf bc/se to use synchronous way when handle concurrenct invocation.

Thanks 
Freeman



> need add lock for DeliveryChannel of cxf bc consumer to handle multiple 
> client invocation
> -----------------------------------------------------------------------------------------
>
>                 Key: SM-1702
>                 URL: https://issues.apache.org/activemq/browse/SM-1702
>             Project: ServiceMix
>          Issue Type: Bug
>          Components: servicemix-cxf-bc
>    Affects Versions: servicemix-cxf-bc-2008.01, 3.2.3, 3.3
>            Reporter: Freeman Fang
>            Assignee: Freeman Fang
>             Fix For: servicemix-cxf-bc-2008.02, 3.3.1, 3.2.4
>
>
> should use
>                     synchronized (context.getDeliveryChannel()) {
>                         context.getDeliveryChannel().sendSync(exchange,
>                             timeout * 1000);
>                     }
> to send out jbi message in sync case

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to