首页 > 解决方案 > spring 集成报错信息路由是如何工作的?

问题描述

我已经配置了我的 spring 集成应用程序来管理这样的错误:

<exception-type-router resolution-required="true" default-output-channel="errorChannelStop" input-channel="error-manager">
    <mapping exception-type="org.springframework.xml.validation.XmlValidationException" channel="formatErrorMessageChannel" />
</exception-type-router>

但是,当我遇到以下异常时,它不会将消息路由到formatErrorMessageChannel通道:

org.springframework.xml.validation.XmlValidationException: Could not validate source: The element type "messageType" must be terminated by the matching end-tag "</messageType>".; 
    nested exception is org.xml.sax.SAXParseException; line number: 9; columnNumber: 24; The element type "message Type" must be terminated by the matching end-tag "</messageType>".
    ...
Caused by: org.xml.sax.SAXParseException: The element type "message Type" must be terminated by the matching end-tag "</messageType>".

为什么 ?

标签: javaerror-handlingspring-integration

解决方案


您需要确保将消息发送到该error-manager. 仅仅抛出一个异常并不能使一切都对你的错误通道起作用。

有关更多信息,请参阅文档:https ://docs.spring.io/spring-integration/docs/5.2.3.RELEASE/reference/html/error-handling.html#error-handling


推荐阅读