[ 
https://issues.apache.org/jira/browse/CAMEL-3698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13000231#comment-13000231
 ] 

Willem Jiang commented on CAMEL-3698:
-------------------------------------

Hi Martijn,

After spending some time to dig the code of CXF HttpConduit and Camel Tracer, I 
just found your rout has an issue of 
[StreamCache|http://camel.apache.org/stream-caching.html].
That explains why you set the log level to INFO the route work as expect. 
Because Camel Trace will log the Exchange when the log level set to INFO, and 
when it log the Exchange, it will try to turn the in message body into a 
StreamCache object. In this way we could reuse the stream in different endpoint.
For your case, your route will send the exchange to another endpoint, so the 
message body should be cacheable. 
{code}
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"; 
trace="true" autoStartup="true">
<route streamCache="true">
    <from uri="cxf:bean:entryEndpoint" />
        <loadBalance>
           <failover>
              <exception>java.lang.Throwable</exception>
           </failover>
           <to uri="cxf:bean:targetEndpoint1" />
           <to uri="cxf:bean:targetEndpoint2" />
        </loadBalance>
</route>
</camelContext>
{code}
 
Willem


> Failover loadbalancing between cxf endpoints results in 
> IllegalStateException: Already connected
> ------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3698
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3698
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-cxf
>    Affects Versions: 2.6.0
>            Reporter: Martijn van Ginkel
>            Assignee: Willem Jiang
>
> I have configured a route with a failover loadbalancer using camel 2.6.0 and 
> cxf 2.3.2 as follows:
> {code:xml}
> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"; 
> trace="true" autoStartup="true">
> <route>
>     <from uri="cxf:bean:entryEndpoint" />
>         <loadBalance>
>            <failover>
>               <exception>java.lang.Throwable</exception>
>            </failover>
>            <to uri="cxf:bean:targetEndpoint1" />
>            <to uri="cxf:bean:targetEndpoint2" />
>         </loadBalance>
> </route>
> </camelContext>{code}
> We have configured two soap services at a local Tomcat, targetEnpoint1 and 2. 
> If 'targetEndpoint1' is stopped (resulting in a 404), I expect the message to 
> fail over to 'targetEndpoint2'. When I switch of the service at 
> 'targetEndpoint1', executing the route results in a IllegalStateException:
> {code}
> 2011-02-21 16:45:24,430 [ERROR] Logger - Failed delivery for exchangeId: 
> ID-MartijnvG-HP-19759-1298303117555-0-2. Exhausted after delivery attempt: 1 
> caught: java.lang.IllegalStateException: IllegalStateException invoking 
> http://localhost:8080/echo2/echo: Already connected
> java.lang.IllegalStateException: IllegalStateException invoking 
> http://localhost:8080/echo2/echo: Already connected
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
>       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
> Source)
>       at java.lang.reflect.Constructor.newInstance(Unknown Source)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2107)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2097)
>       at 
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
>       at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:697)
>       at 
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
>       at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:454)
>       at 
> org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:94)
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
>       at 
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)
>       at 
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)
>       at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
>       at 
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
>       at 
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
>       at 
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)
>       at 
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)
>       at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
>       at 
> org.apache.camel.processor.loadbalancer.FailOverLoadBalancer.processExchange(FailOverLoadBalancer.java:226)
>       at 
> org.apache.camel.processor.loadbalancer.FailOverLoadBalancer.access$300(FailOverLoadBalancer.java:38)
>       at 
> org.apache.camel.processor.loadbalancer.FailOverLoadBalancer$FailOverAsyncCallback.done(FailOverLoadBalancer.java:286)
>       at 
> org.apache.camel.processor.DefaultChannel$1.done(DefaultChannel.java:275)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:639)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler.processAsyncErrorHandler(RedeliveryErrorHandler.java:368)
>       at 
> org.apache.camel.processor.RedeliveryErrorHandler$1.done(RedeliveryErrorHandler.java:317)
>       at 
> org.apache.camel.management.InstrumentationProcessor$1.done(InstrumentationProcessor.java:78)
>       at 
> org.apache.camel.component.cxf.CxfClientCallback.handleException(CxfClientCallback.java:85)
>       at 
> org.apache.cxf.interceptor.ClientOutFaultObserver.onMessage(ClientOutFaultObserver.java:59)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:2203)
>       at 
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:253)
>       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown 
> Source)
>       at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>       at java.lang.Thread.run(Unknown Source)
> Caused by: java.lang.IllegalStateException: Already connected
>       at java.net.HttpURLConnection.setFixedLengthStreamingMode(Unknown 
> Source)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1937)
>       at 
> org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2029)
>       ... 38 more
> {code}
> The failover does not work. However when I change the loglevel of 
> _org.apache.camel.processor.interceptor.Tracer_ from WARN to INFO in my 
> log4j.properties, the failover does work as expected. In both cases tracing 
> is enabled.
> I believe this is a bug since the behaviour of the failover changes if the 
> log level is changed.
> We were able to reproduce this behaviour on multiple systems. If you have any 
> problems reproducing this behaviour we are happy to provide more information 
> or an example project.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to