I'm using Camel 2.9.1 with Spring 3.1.1.RELEASE and ActiveMQ 5.5.1.
I have a Swing GUI client which is using Camel JMS to make @InOut
request-reply calls to a data service which is running in a bundle in a Karaf/Felix OSGi container on our server.
This service, in certain circumstances, throws exceptions which we want to deal with in the client.
When these exceptions are thrown, Camel passes them back to the Client wrapped in a RuntimeCamelException
and it all works fine.
But now I would like to suppress the stacktrace that Camel seems to log automatically when the Exception passes back to the client. Here's a snippet from the server's Log:
2012-11-01 13:04:13,463 | ERROR | org.apache.camel.util.CamelLogger | Failed delivery for (MessageId: ID-pc01-48122-1351720826468-9-121549 on ExchangeId: ID-pc01-48122-1351720826468-9-121547). Exhausted after delivery attempt: 1 caught:org.apache.camel.RuntimeCamelException: our.own.SomethingException: Some explanation of exception here
org.apache.camel.RuntimeCamelException: our.own.SomethingException: Some explanation of exception here
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:87)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:128)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
... etc.
which is immediately followed in the log with:
2012-11-01 13:04:13,517 | WARN | org.apache.camel.util.CamelLogger | Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - our.own.SomethingException: Some explanation of exception here]
org.apache.camel.RuntimeCamelException: our.own.SomethingException: Some explanation of exception here
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:87)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:128)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[120:org.apache.camel.camel-core:2.9.1]
...etc
Now the Spring file for the Client has the folowing definition:
<bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://${current.host}:${current.port}?jms.prefetchPolicy.queuePrefetch=0"/>
<property name="transacted" value="false"/>
<property name="requestTimeout" value="60000"/>
<property name="transferException" value="true"/>
<property name="errorHandlerLogStackTrace" value="false"/>
<property name="concurrentConsumers" value="1"/>
<property name="maxConcurrentConsumers" value="1"/>
</bean>
Which has the errorHandlerLogStackTrace
property set to 'false', so I'm not sure why it's still logging the stacktraces.
Do I need to have a similar property setting on the server side (since this is the server log which contains the stacktraces)?
By the way, most of this stuff was set up by a previous employee who no longer works for us. Although I have a fairly good understanding of what's going on, some of it is still a mystery to me.
UPDATE: 5/11/12 - After Claus's answer
OK, I went digging a bit more through the Spring DSL XML files and found that the JMS Component was being defined on the server in a separate OSGi bundle called 'broker' which the other server bundles were referring to. This bundle had the same XML definition of the 'jms' bean as the client had (above).
I added the 'errorHandlerLogStackTrace' property to this definition and this has managed to get rid of one of the stack-traces. What I'm getting now is an ERROR with a stack-trace, followed immediately by a WARN without a stack-trace. Here's a more complete snippet:
2012-11-05 10:44:35,323 | ERROR | org.apache.camel.util.CamelLogger | Failed delivery for (MessageId: ID-pc01-38192-1352065125718-9-62 on ExchangeId: ID-pc01-38192-1352065125718-9-60). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeCamelException: our.own.SomethingException: Some explanation of exception here
org.apache.camel.RuntimeCamelException: our.own.SomethingException: Some explanation of exception here
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:87)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:128)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:333)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)[120:org.apache.camel.camel-core:2.9.1]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:104)[147:org.apache.camel.camel-jms:2.9.1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:562)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:500)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:326)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:264)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1063)[63:org.springframework.jms:3.1.1.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:960)[63:org.springframework.jms:3.1.1.RELEASE]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_24]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_24]
at java.lang.Thread.run(Thread.java:662)[:1.6.0_24]
Caused by: our.own.SomethingException: Some explanation of exception here
at uniworks.ServiceManagers.SuperDataManager.createInUseForEntity(SuperDataManager.java:2156)[220:uniworks-ejb:1.1.4.SNAPSHOT]
at uniworks.ServiceManagers.SuperDataManager.findForEdit(SuperDataManager.java:913)[220:uniworks-ejb:1.1.4.SNAPSHOT]
at uniworks.ServiceManagers.SuperDataManager.findForEdit(SuperDataManager.java:853)[220:uniworks-ejb:1.1.4.SNAPSHOT]
at uniworks.ServiceManagers.SuperDataManager.findForEdit(SuperDataManager.java:843)[220:uniworks-ejb:1.1.4.SNAPSHOT]
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_24]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)[65:org.springframework.transaction:3.1.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)[55:org.springframework.aop:3.1.1.RELEASE]
at $Proxy221.findForEdit(Unknown Source)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_24]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)[90:org.springframework.osgi.core:1.2.1]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[55:org.springframework.aop:3.1.1.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)[55:org.springframework.aop:3.1.1.RELEASE]
at $Proxy1044.findForEdit(Unknown Source)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_24]
at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_24]
at org.apache.camel.component.bean.BeanInvocation.invoke(BeanInvocation.java:83)[120:org.apache.camel.camel-core:2.9.1]
... 46 more
2012-11-05 10:44:35,335 | WARN | org.apache.camel.util.CamelLogger | Execution of JMS message listener failed. Caused by: [our.own.SomethingException: Some explanation of exception here]
Now, what might be complicating these here is the 'path' that this method call takes.
The client uses a JMS Request-Reply message to call the server using the following route definiition:
<bean id="animalTypeDataManager" class="org.apache.camel.spring.remoting.CamelProxyFactoryBean">
<property name="serviceUrl" value="jms:animalTypeDataManager"/>
<property name="serviceInterface" value="uniworks.ServiceManagers.a.Animal.AnimalTypeDataInterface"/>
</bean>
The server end of that route is defined in one OSGi bundle (lets call 'BundleA') as follows:
<camel:route>
<camel:from uri="jms:animalTypeDataManager"/>
<camel:to uri="bean:osgi_animalTypeDataManager"/>
</camel:route>
The bean referred to in this route is actually in another bundle ('BundleB') as an OSGi 'service'. BundleA has reference to this bean defined as follows:
<reference id="osgi_animalTypeDataManager"
interface="uniworks.ServiceManagers.a.Animal.AnimalTypeDataInterface"/>
And BundleB has the service defined as follows:
<service id="osgi_animalTypeDataManager" ref="animalTypeDataManager"
interface="uniworks.ServiceManagers.a.Animal.AnimalTypeDataInterface"/>
It is this final service bean that is throwing the Exception.
I could put an errorHandler
on each of the server ends of these routes (in BundleA), but I'd like to be able to do this generically in one place.
I tried defining a logging error handler (as per the Camel Documentation) in BundleA as follows:
<camel:errorHandler id="loggingErrorHandler" type="LoggingErrorHandler" logName="mylogger.name" level="DEBUG"/>
<camel:camelContext id="bundleA_camel" errorHandlerRef="loggingErrorHandler">
..... [jms routes defined in here]
</camel:context>
But that did not seem to make any difference.
The 1st log with the stacktrace is from Camel's error handler which by default log exhausted failures at ERROR level with stacktrace. You can configure this to your likings. See details at Camel's error handler docs. http://camel.apache.org/error-handling-in-camel.html
The 2nd log is from the JmsConsumer and the option errorHandlerLogStackTrace=false, ought to force it to not log the stack trace. I am not sure if Camel 2.9.1 has a bug in this area. I tried on latest Camel and it works fine there.
Here is an unit test which may help you http://svn.apache.org/viewvc?rev=1405307&view=rev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With