On Tue, Jul 19, 2011 at 1:21 PM, James Talbut <jtalbut@tardis.spudsoft> wrote: > That's it! > The org.apache.camel.processor.interceptor.TraceInterceptor doesn't work > properly for Async processing. > > It has: > try { > // special for interceptor where we need to keep booking how > far we have routed in the intercepted processors > if (node.getParent() instanceof InterceptDefinition && > exchange.getUnitOfWork() != null) { > TracedRouteNodes traced = > exchange.getUnitOfWork().getTracedRouteNodes(); > traceIntercept((InterceptDefinition) node.getParent(), > traced, exchange); > } > > // process the exchange > try { > sync = super.process(exchange, callback); > } catch (Throwable e) { > exchange.setException(e); > } > } finally { > // after (trace out) > if (shouldLog && tracer.isTraceOutExchanges()) { > logExchange(exchange); > traceExchangeOut(exchange, traceState); > } > } > > But the call to super.process needs to wrap the callback to call > traceExchangeOut (and the finally block shouldn't run if the process is > asynch). > > Shall I file a Jira? >
Yep you bet, and you are welcome to work on a patch as well. > Jim > > > On Tue, Jul 19, 2011 at 01:11:37PM +0200, Claus Ibsen wrote: >> On Tue, Jul 19, 2011 at 1:10 PM, James Talbut <jtalbut@tardis.spudsoft> >> wrote: >> > Willem, >> > >> > I think I've narrowed it down to saying that when it's asynchronous the >> > TraceHandler is being called before the Out message is available, whereas >> > when it is synchronous >> > the TraceHandler is not called until the Out message is ready. >> > I suspect this means it's called as soon as the CXF message has left (i.e. >> > before any reply is seen), but it's not very easy to prove that. >> > >> >> Sounds as if the downstream logic (that TraceHandler) is not in place >> in the AsyncCallback code block. To support both sync and async the >> code should be in both places. >> >> >> >> >> > Jim >> > >> > >> > On Tue, Jul 19, 2011 at 11:58:35AM +0100, James Talbut wrote: >> >> Willem, >> >> >> >> Yes, that works (obviously missing out on the benefits of Asynch). >> >> >> >> The two MessageLoggers are based on the code in the CXF message loggers - >> >> they use the same techniques to capture the on-the-wire message and then: >> >> MessageLoggerOut simply logs the message along with a correlation ID >> >> found in the CXF headers (put there by the TraceHandler). >> >> MessageLoggerIn puts the entire message as a header in the CxfMessage, >> >> this is then picked up by the TraceHandler to be logged. >> >> >> >> The aim is to capture the on-the-wire messages and to associate them with >> >> the trace (obviously this is not particularly helpful for PAYLOAD >> >> dataFormat, but it's used for >> >> POJO too). >> >> >> >> I've got all the CXF and Camel logging turned up to full to try to work >> >> out why I'm losing that inbound message, if it'd help I can send the >> >> relevant bits of those. >> >> >> >> Jim >> >> >> >> >> >> On Tue, Jul 19, 2011 at 06:40:16PM +0800, Willem Jiang wrote: >> >> > What are the MessageLogger{In|Out}bound doing ? >> >> > Can you try to change your route like this to see if the error goes out? >> >> > >> >> > <camel:route> >> >> > <camel:from >> >> > uri="cxf:bean:serviceGroups?dataFormat=PAYLOAD&synchronous=false"/> >> >> > <camel:to >> >> > uri="cxf:bean:targetGroups?dataFormat=PAYLOAD&synchronous=true"/> >> >> > </camel:route> >> >> > >> >> > On 7/19/11 6:20 PM, James Talbut wrote: >> >> > > Willem, >> >> > > >> >> > > I'm afraid I can't give you the actual WSDL and URLs (they're from a >> >> > > third party), but I don't think they'll make a difference, they just >> >> > > return a soap:Fault. >> >> > > >> >> > > The route (and associated config) is: >> >> > > <bean id="traceHandler" >> >> > > class="com.groupgti.routemaster.trace.test.RouteMasterLoggingTraceHandler" >> >> > > xmlns:cxf="http://camel.apache.org/schema/cxf"/> >> >> > > <bean id="soapFaultConverter" >> >> > > class="com.groupgti.routemaster.soapFaultConverter.SoapFaultConverter" >> >> > > xmlns:cxf="http://camel.apache.org/schema/cxf"/> >> >> > > >> >> > > <bean id="tracer" >> >> > > class="org.apache.camel.processor.interceptor.Tracer"> >> >> > > <property name="traceHandler" ref="traceHandler"/> >> >> > > <property name="enabled" value="true"/> >> >> > > <property name="traceOutExchanges" value="true"/> >> >> > > <property name="logLevel" value="OFF"/> >> >> > > </bean> >> >> > > >> >> > > <bean id="cxfInboundLoggingInterceptor" >> >> > > class="com.groupgti.routemaster.cxf.interceptors.test.MessageLoggerInbound"/> >> >> > > <bean id="cxfOutboundLoggingInterceptor" >> >> > > class="com.groupgti.routemaster.cxf.interceptors.test.MessageLoggerOutbound"/> >> >> > > >> >> > > <cxf:bus> >> >> > > <cxf:inInterceptors> >> >> > > <ref bean="cxfInboundLoggingInterceptor"/> >> >> > > </cxf:inInterceptors> >> >> > > <cxf:outInterceptors> >> >> > > <ref bean="cxfOutboundLoggingInterceptor"/> >> >> > > </cxf:outInterceptors> >> >> > > <cxf:inFaultInterceptors> >> >> > > <ref bean="cxfInboundLoggingInterceptor"/> >> >> > > </cxf:inFaultInterceptors> >> >> > > <cxf:outFaultInterceptors> >> >> > > <ref bean="cxfOutboundLoggingInterceptor"/> >> >> > > </cxf:outFaultInterceptors> >> >> > > </cxf:bus> >> >> > > >> >> > > <camel-cxf:cxfEndpoint >> >> > > xmlns:ns="http://schemas.datacontract.org/..." >> >> > > id="targetGroups" >> >> > > address="https://remotehost/..." >> >> > > wsdlURL="http://..." >> >> > > serviceName="ns:Groups" >> >> > > endpointName="ns:GroupsSoap" >> >> > > serviceClass="GroupsSoap"/> >> >> > > >> >> > > <camel-cxf:cxfEndpoint >> >> > > xmlns:ns="http://schemas.datacontract.org/.." >> >> > > id="serviceGroups" >> >> > > address="http://localhost:9000/..." >> >> > > wsdlURL="http://..." >> >> > > serviceName="ns:Groups" >> >> > > endpointName="ns:GroupsSoap"/> >> >> > > >> >> > > <camel:camelContext id="sampleHashCamelContext"> >> >> > > >> >> > > <camel:route> >> >> > > <camel:from >> >> > > uri="cxf:bean:serviceGroups?dataFormat=PAYLOAD&synchronous=false"/> >> >> > > <camel:to >> >> > > uri="cxf:bean:targetGroups?dataFormat=PAYLOAD&synchronous=false"/> >> >> > > </camel:route> >> >> > > >> >> > > </camel:camelContext> >> >> > > >> >> > > >> >> > > >> >> > > Changing the dataFormat doesn't seem to make any difference. >> >> > > The "synchronous=false" was added just to see if I could make it hit >> >> > > the problem under the debugger, and it does hit it there now. >> >> > > >> >> > > It looks like the Camel TraceHandler is being called before the CXF >> >> > > interceptor, but at this stage I can't work out how that happens. >> >> > > >> >> > > Thanks. >> >> > > >> >> > > Jim >> >> > > >> >> > > >> >> > > On Tue, Jul 19, 2011 at 06:04:16PM +0800, Willem Jiang wrote: >> >> > >> Can you post your route, or submit a simple test case to show the >> >> > >> error ? >> >> > >> It look like a time issue of CXF endpoint which is working in async >> >> > >> module by default. But I cannot tell more just by looking up the >> >> > >> description that you gave in the mail. >> >> > >> >> >> > >> >> >> > >> >> >> > >> On 7/19/11 4:43 PM, James Talbut wrote: >> >> > >>> Hi, >> >> > >>> >> >> > >>> I'm using a combination of a Camel TraceHandler and a CXF >> >> > >>> interceptor to capture on-the-wire messages and log them with the >> >> > >>> Camel message. >> >> > >>> In normal use this all works, but when I have an error the Camel >> >> > >>> TraceHandler isn't being called (the rest of the route is picking >> >> > >>> up the error correctly, it's just the >> >> > >>> tracing that isn't working). >> >> > >>> >> >> > >>> When I run under the debugger everything works as expected. >> >> > >>> When I add synchronous=true to the CXF endpoints everything works >> >> > >>> as expected. >> >> > >>> >> >> > >>> Anyone got any ideas or suggestions for where I should look? >> >> > >>> >> >> > >>> This is with Camel 2.7.1, running on Windows. >> >> > >>> >> >> > >>> Thanks. >> >> > >>> >> >> > >>> Jim >> >> > >>> >> >> > >> >> >> > >> >> >> > >> -- >> >> > >> 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 >> > >> >> >> >> -- >> Claus Ibsen >> ----------------- >> FuseSource >> Email: cib...@fusesource.com >> Web: http://fusesource.com >> Twitter: davsclaus, fusenews >> Blog: http://davsclaus.blogspot.com/ >> Author of Camel in Action: http://www.manning.com/ibsen/ > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/