繁体   English   中英

如何在Spring Integration中的异常路由器中使用根本原因异常类型

[英]How to use root cause Exception type in Exception Router in Spring Integration

我试图在我的代码中处理异常。 但是,Messaging Exception包装了代码抛出的自定义异常。

现在我想使用Exception路由器,如果类型是我的自定义异常,那么我想将消息发送到队列a,否则队列b。

现在问题是,路由器正在接收消息传递异常对象,因此它无法识别我的异常,并且正在将消息发送到队列b,而异常根本原因仍然是我的自定义异常。

路由器如下:

 <int:exception-type-router input-channel="exceptionRouterChannel" 
     default-output-channel="unpersistedDest">
    <int:mapping exception-type=
                    "org.springframework.integration.MessageRejectedException"
        channel="validationErrorsDest" />
    <int:mapping exception-type=
                        "com.error.StaleMessageException"
        channel="discardDest" />
</int:exception-type-router>       

任何人都可以帮助这个。

实际上,没有理由map到消息传递异常。 ErrorMessageExceptionTypeRoutercause.getCause()执行循环: https//github.com/spring-projects/spring-integration/blob/master/spring-integration-core/src/main/java/org/springframework/integration/router /ErrorMessageExceptionTypeRouter.java#L41

因此,您只能映射您的例外情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM