Hi When you use http based routes, then the message is most likely stream based. And then you have to a bit more careful, as reading a stream message may only be possible once.
So either enable stream caching in Camel. http://camel.apache.org/stream-caching.html Or convert the message to a String, which is safe to be read multiple times. We added a note on the wire-tap EIP page about this, just below the first diagram http://camel.apache.org/wire-tap On Thu, Apr 26, 2012 at 4:36 AM, mccabejj <mccab...@gmail.com> wrote: > Hello, > > I am experiencing an intermittent issue with WireTap on HTTP component based > routes. I feel like I have exhausted my resources (both in the Camel > documentation, and on the forum) so I thought to post what I'm seeing. I > will try to keep it as succint as possible. Thanks in advance for reading > through this long post and trying to help me figure out what I'm doing > wrong. > > *Camel Version - 2.9.2 (originally noticed it on 2.8.2 so tried upgrading to > the latest)* > > *Overview:* Camel is being used to route, transform, and audit HTTP requests > with an XML payload. Posts are made to a Servlet which marshals the request > to the appropriate Camel route through to the endpoint and back out through > the Servlet. For auditing the WireTap component is used to asynchronously > log the XML requests and responses to a datastore. > > *Route:* > <routes streamCache="false" xmlns="http://camel.apache.org/schema/spring"> > <route id="/gateway/services/tax/ComputeTax"> > <from uri="direct:gateway/services/tax/ComputeTax"/> > <bean ref="camelDefaultRequestProcessor"/> > <wireTap uri="direct:gateway/services/LogRequest"/> > <setHeader > headerName="serviceStaticId"><constant>919589842</constant></setHeader> > <bean ref="camelAuthenticationRequestProcessor"/> > <to uri="xslt:client/xslt/addSecurityNamespace.xsl"/> > <to > uri="http://${SUBSTITUTE_SERVER_NAME}:${SUBSTITUTE_SERVER_PORT}/tax/services/ComputeTax?bridgeEndpoint=true&transferException=true"/> > <wireTap uri="direct:gateway/services/LogResponse"> > <body><simple>${body}</simple></body> > </wireTap> > <onException> > > <exception>com.efleets.services.gateway.security.ServiceSecurityException</exception> > <redeliveryPolicy maximumRedeliveries="0"/> > <handled><constant>true</constant></handled> > <bean ref="camelFailureResponseStrategy"/> > <wireTap uri="direct:gateway/services/LogResponse"> > <body><simple>${body}</simple></body> > </wireTap> > </onException> > <onException> > > <exception>org.apache.camel.component.http.HttpOperationFailedException</exception> > <redeliveryPolicy maximumRedeliveries="0"/> > <handled><constant>true</constant></handled> > <bean ref="camelFailureResponseStrategy"/> > <wireTap > uri="direct:gateway/services/LogResponse"> > <body><simple>${body}</simple></body> > </wireTap> > </onException> > </route> > </routes> > > *The WireTap - "log" route:* > <routes xmlns="http://camel.apache.org/schema/spring"> > <route id="/gateway/services/LogRequest"> > <from uri="direct:gateway/services/LogRequest"/> > <bean ref="camelLogProcessor" method="logRequest"/> > <to > uri="http://${SUBSTITUTE_SERVER_NAME}:${SUBSTITUTE_SERVER_PORT}/logging/services/Log?httpClient.soTimeout=5000&bridgeEndpoint=true&transferException=false"/> > </route> > </routes> > > *Issue:* > The above routes work MOST of the time. However, under Load conditions (X > number of transactions in varying intervals - 30s, 60s, etc.) a small but > varying percentage (sometimes 10% other times 0%) of the WireTap log > requests end up failing. It is ALWAYS the response that fails to log (the > 2nd WireTap). Based on what I see in the debug the WireTap/Log route is > always executing, but for those that fail the payload coming to the > "camelLogProcessor" bean is NULL/EMPTY. This causes the Log to fail. > > *Here is a sample of the exception:* > /2012-04-25 20:50:10,417|DEBUG|desktop|||Camel (camelContext) thread #5 - > WireTapThread|impl.CamelLogProcessor|Start - CamelLogProcessor.logResponse() > 2012-04-25 20:50:10,417|WARN|desktop|||Camel (camelContext) thread #5 - > WireTapThread|impl.CamelLogProcessor|LogResponse: XML Payload is null or > empty. Unable to log the response for > transmissionId=da261865-1320-4a3c-a61e-c9c60e0fab5d > 2012-04-25 20:50:10,433|ERROR|desktop|||Camel (camelContext) thread #5 - > WireTapThread|processor.DefaultErrorHandler|Failed delivery for (MessageId: > ID-2ua0270ghk-2665-1335404894183-0-6 on ExchangeId: > ID-2ua0270ghk-2665-1335404894183-0-7). Exhausted after delivery attempt: 1 > caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP > operation failed invoking http://<server:port>/logging/services/Log with > statusCode: 500/ > > I've tried a modified version of the route that utilizes a ThreadPool > specifically for the WireTap (by specifying an executorServiceRef on the > wireTap element), but in general the behavior is the same. Note: I've > adjusted the poolSize, maxPoolSize, and etc but nothing seemed to help. > > *Here is the ThreadPool:* > <threadPool id="wireTapThreadPool" threadName="WireTapThread" poolSize="10" > maxPoolSize="20" maxQueueSize="-1" rejectedPolicy="CallerRuns"/> > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Http-Route-with-WireTap-Question-Issue-tp5666526p5666526.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com 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/