【问题标题】:Cannot stop logging of stacktrace with Camel ActiveMQ JMS无法停止使用 Camel ActiveMQ JMS 记录堆栈跟踪
【发布时间】:2012-11-01 00:40:16
【问题描述】:

我将 Camel 2.9.1 与 Spring 3.1.1.RELEASE 和 ActiveMQ 5.5.1 一起使用。

我有一个 Swing GUI 客户端,它使用 Camel JMS 对数据服务进行 @InOut 请求-回复调用,该数据服务在我们服务器上的 Karaf/Felix OSGi 容器的捆绑包中运行。

此服务在某些情况下会引发我们希望在客户端处理的异常。

当这些异常被抛出时,Camel 将它们传递回包裹在 RuntimeCamelException 中的客户端,一切正常。

但是现在我想抑制当异常传回客户端时 Camel 似乎自动记录的堆栈跟踪。这是来自服务器日志的 sn-p:

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.

在日志中紧随其后的是:

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

现在 Client 的 Spring 文件具有以下定义:

<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>

errorHandlerLogStackTrace 属性设置为“false”,所以我不确定它为什么仍在记录堆栈跟踪。

我是否需要在服务器端进行类似的属性设置(因为这是包含堆栈跟踪的服务器日志)?

顺便说一句,这些东西大部分是由不再为我们工作的前员工设置的。虽然我对正在发生的事情有相当好的了解,但其中一些对我来说仍然是个谜。

更新:2012 年 5 月 11 日 - 在克劳斯的回答之后

好的,我深入研究了 Spring DSL XML 文件,发现 JMS 组件是在服务器上定义的一个单独的 OSGi 包中,称为“代理”,其他服务器包所指的是该包。此捆绑包具有与客户端相同的“jms”bean 的 XML 定义(上图)。

我在此定义中添加了“errorHandlerLogStackTrace”属性,这已成功摆脱了堆栈跟踪之一。我现在得到的是一个带有堆栈跟踪的错误,然后是一个没有堆栈跟踪的 WARN。这是一个更完整的sn-p:

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]

现在,这里可能使这些复杂化的是此方法调用所采用的“路径”。

客户端使用 JMS Request-Reply 消息调用使用以下路由定义的服务器:

<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>

该路由的服务器端在一个 OSGi 包中定义(让我们调用“BundleA”),如下所示:

<camel:route>
    <camel:from uri="jms:animalTypeDataManager"/>
    <camel:to uri="bean:osgi_animalTypeDataManager"/>
</camel:route>

此路由中引用的 bean 实际上作为 OSGi“服务”位于另一个捆绑包 ('BundleB') 中。 BundleA 对这个 bean 的引用定义如下:

<reference id="osgi_animalTypeDataManager" 
           interface="uniworks.ServiceManagers.a.Animal.AnimalTypeDataInterface"/>

而BundleB的服务定义如下:

<service id="osgi_animalTypeDataManager" ref="animalTypeDataManager" 
         interface="uniworks.ServiceManagers.a.Animal.AnimalTypeDataInterface"/>

正是这个最终的服务 bean 抛出了异常。

我可以在这些路由的每个服务器端(在 BundleA 中)放置一个 errorHandler,但我希望能够在一个地方通用地执行此操作。

我尝试在 BundleA 中定义一个日志记录错误处理程序(根据 Camel Documentation),如下所示:

<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>

但这似乎没有任何区别。

【问题讨论】:

  • 您能否提供更多信息,例如您的路线、错误处理程序等?
  • @Petter,请参阅上面的编辑。目前没有定义errorHandler(除了我上面描述的尝试)所以它应该使用默认的errorHandler。

标签: java exception activemq apache-camel


【解决方案1】:

带有堆栈跟踪的第一个日志来自 Camel 的错误处理程序,默认情况下,该处理程序使用堆栈跟踪记录 ERROR 级别的故障。您可以根据自己的喜好进行配置。请参阅 Camel 的错误处理程序文档中的详细信息。 http://camel.apache.org/error-handling-in-camel.html

第二个日志来自 JmsConsumer 和选项 errorHandlerLogStackTrace=false,应该强制它不记录堆栈跟踪。我不确定 Camel 2.9.1 在这方面是否存在错误。我尝试了最新的 Camel,它在那里运行良好。

这是一个可以帮助你的单元测试 http://svn.apache.org/viewvc?rev=1405307&view=rev

【讨论】:

  • 你给了我更多关于要寻找什么的指示,我已经取得了一些进展(请参阅我的问题的编辑),但我只设法摆脱了其中一个堆栈-痕迹。
  • 你能否尝试在每个 上指定 errorHandlerRef。这曾经是一个错误,在 XML DSL 中 上的 errorHandlerRef 无法正常工作。
  • 参考去哪里了?在&lt;camel:route&gt;&lt;camel:to uri="bean:....."&gt; 上?还是没关系?
  • 我将 loggingErrorHandler 定义为上述 outside 骆驼上下文,并在将受影响的 bean 作为 to 端点的上下文内定义的路由上,我添加了errorHandlerRef="loggingErrorHandler" 属性,并且堆栈跟踪仍然出现在日志中。
  • 有没有办法在所有路由定义周围使用doTry ... doCatch,允许异常传播回客户端,但不记录堆栈跟踪?
【解决方案2】:

好的,经过克劳斯的提示,以及骆驼文档here的部分,我终于设法摆脱了堆栈跟踪。

在 Camel 上下文的 Spring DSL 定义包含获取 JMS 消息并将它们传递到 bean 引用的路由之前,我定义了一个 noErrorHandler 的实例,如下所示:

<camel:errorHandler id="noErrorHandler" type="NoErrorHandler"/>

然后,我将该错误处理程序添加到 Camel 上下文本身,因此:

<camel:camelContext id="bundle_camel" errorHandlerRef="noErrorHandler">

现在,bean 抛出的任何异常都将传播回调用者,而无需 Camel 记录堆栈跟踪。

【讨论】:

    【解决方案3】:

    您也可以使用 logExhausted(false)

    onException(Exception.class)
                .handled(true)
                .logExhausted(false)
    

    【讨论】:

      猜你喜欢
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 2014-11-01
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      • 2014-01-06
      相关资源
      最近更新 更多