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