【问题标题】:Spring Integration: error-channel - Problems with exception handlingSpring Integration:错误通道 - 异常处理问题
【发布时间】:2014-03-03 05:25:36
【问题描述】:

您好,这是我的配置:

  1. JVM 1.6.0_30
  2. 春季版 3.0.5
  3. Spring 集成核心 2.0.5
  4. S.O.视窗 7

这是我的上下文配置:

<beans:bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
    lazy-init="false">
    <beans:property name="ignoreUnresolvablePlaceholders"
        value="true" />
    <beans:property name="location" value="classpath:etc/pds/pds.properties" />
</beans:bean>



<channel id="pdsrequest" />
<channel id="pdsresponse" />
<channel id="channelMBD"/>

<channel id="pdsRisposta">
    <queue capacity="1" />
    <interceptors>
        <wire-tap channel="simple" />
    </interceptors>
</channel>

<service-activator input-channel="pdsrequest"
    output-channel="pdsresponse" ref="pdsCalculateService" />

<logging-channel-adapter id="simple" level="DEBUG" />

<!-- GATEWAY -->
<gateway id="gatewayService"
    service-interface="com.cervedgroup.rating.pds.orchestratore.spring.GatewayService"
    error-channel="errorChannel" default-reply-timeout="${PDS.GATEWAY_TIMEOUT}"
    default-request-channel="pdsrequest" default-reply-channel="pdsresponse" />


<exception-type-router input-channel="errorChannel">
    <mapping
        exception-type="com.cervedgroup.rating.pds.exceptions.NotDefinedPDSException"
        channel="eccezioneProgrammata" />
    <mapping exception-type="com.cervedgroup.rating.pds.exceptions.ComputingPDSException"
        channel="eccezioneRuntime" />
    <mapping
        exception-type="com.cervedgroup.rating.pds.exceptions.DataSourcePDSException"
        channel="eccezioneRuntime" />
    <mapping exception-type="com.cervedgroup.rating.pds.exceptions.PDSException"
        channel="eccezioneRuntime" />
    <mapping
        exception-type="com.cervedgroup.rating.pds.exceptions.ConfigurationException"
        channel="eccezioneRuntime" />
    <mapping exception-type="java.lang.RuntimeException" channel="eccezioneRuntime" />
</exception-type-router>

<service-activator input-channel="eccezioneProgrammata"
    ref="invokerHandlerEccezioneProgrammata" />

<beans:bean id="invokerHandlerEccezioneProgrammata"
    class="com.cervedgroup.rating.pds.orchestratore.error.GestoreEccezioneProgrammata" />

<service-activator input-channel="eccezioneRuntime"
    ref="invokerHandlerEccezioneRuntime" />

<beans:bean id="invokerHandlerEccezioneRuntime"
    class="com.cervedgroup.rating.pds.orchestratore.error.GestoreEccezioneRuntime" />


/>

</beans:beans> 

这是我的 log4j.properties:

log4j.rootLogger=INFO, ROOT
log4j.appender.ROOT=org.apache.log4j.ConsoleAppender
log4j.appender.ROOT.layout=it.pitagora.util.log.CervedLayout
log4j.appender.ME=it.pitagora.util.log.CurrentLoggerAppender
log4j.logger.org.springframework.batch.core.launch.support.CommandLineJobRunner=DEBUG, ME
log4j.logger.org.springframework.integration=OFF, ME
log4j.logger.httpclient.wire.header=INFO,ME
log4j.logger.httpclient.wire.content=INFO,ME
log4j.logger.org.apache.commons.httpclient=INFO,ME
log4j.appender.C=it.pitagora.util.log.CurrentLoggerAppender
log4j.appender.R=it.pitagora.util.log.CurrentLoggerAppender
log4j.appender.D=it.pitagora.util.log.CurrentLoggerAppender
log4j.appender.P=it.pitagora.util.log.CurrentLoggerAppender
log4j.appender.AP=it.pitagora.util.log.CurrentLoggerAppender
log4j.appender.N=it.pitagora.util.log.CurrentLoggerAppender
log4j.logger.org.apache.ibatis=INFO, ME
log4j.logger.org.mybatis.spring=INFO, ME
log4j.logger.org.springframework=INFO, ME

网关的错误通道管理有问题。该通道工作,但在 nohup 上打印异常的堆栈跟踪:

   ERROR 06-02 10:24:07,141 - org.springframework.integration.MessageHandlingException: com.cervedgroup.rating.pds.exceptions.NotDefinedPDSException: Dati non recuperabili
        at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76)
        at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:64)
        at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:98)
        at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
        at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
        at org.springframework.integration.dispatcher.UnicastingDispatcher.access$000(UnicastingDispatcher.java:51)
        at org.springframework.integration.dispatcher.UnicastingDispatcher$1.run(UnicastingDispatcher.java:92)
        at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: com.cervedgroup.rating.pds.exceptions.NotDefinedPDSException: Dati  non recuperabili
        at com.cervedgroup.rating.pds.dao.cgr.RecuperaDatiCGR.recuperaClasseCGRValida(RecuperaDatiCGR.java:218)
        at com.cervedgroup.rating.pds.evaluation.PDSDataRetriever.recuperaClasseCGR(PDSDataRetriever.java:93)
        at com.cervedgroup.rating.pds.evaluation.PDSDataRetriever.recuperaDatiPreliminariGriglie(PDSDataRetriever.java:52)
        at com.cervedgroup.rating.pds.evaluation.PDSDataRetriever.evaluate(PDSDataRetriever.java:38)
        at com.cervedgroup.rating.pds.orchestratore.invoker.PDSDataRetrieverInvoker.avviaDataRetrieving(PDSDataRetrieverInvoker.java:58)
        at com.cervedgroup.rating.pds.orchestratore.invoker.PDSDataRetrieverInvoker.invoke(PDSDataRetrieverInvoker.java:32)
        at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
        at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:83)
        at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
        at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
        at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
        at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
        at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:225)
        at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:125)
        at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
        ... 10 more

有没有办法避免在 nohup 上出现这种打印?

非常感谢

【问题讨论】:

    标签: java spring spring-mvc spring-integration


    【解决方案1】:

    如您所知,errorChannel 是由 Framework 在后台创建的,但没有限制自己定义它。

    默认情况下它是PublishSubscribeChannel,并且框架为它订阅一个处理程序 - LoggingHandlerERROR 日志记录级别。

    因此,如果您对该默认行为不感兴趣,您可以声明 errorChannel,因为它适合您的环境。

    从另一方面来说,当你在&lt;gateway&gt;使用它时,如何使用你自己的频道而不是默认的errorChannel

    【讨论】:

    • 非常感谢,现在重新定义通道错误不会在 nohup 上打印任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-11
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    相关资源
    最近更新 更多