首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何避免int-xml:validating filter中的Spring Integration致命错误?

如何避免int-xml:validating filter中的Spring Integration致命错误?
EN

Stack Overflow用户
提问于 2014-07-17 02:54:18
回答 1查看 413关注 0票数 0

我有一个spring集成应用程序,可以处理队列中的消息并将它们发送到不同的队列。只要XML是有效的,它对所有预期的消息类型都很有效。我定义了一个错误通道来处理异常情况,如验证失败、路由失败等。

对于错误测试,我插入了一个带有不匹配标记的坏XML消息来测试错误处理。不幸的是,我在eclipse的控制台中得到的输出如下:

代码语言:javascript
复制
[Fatal Error] :1:156: The end-tag for element type "Header" must end with a '>' delimiter

它不会将消息路由到错误流,在错误流中,状态将从挂起更新为错误。

看起来Spring Integration本身无法处理这种情况。我预计会发生异常,并让它将消息路由到定义的错误通道。

任何帮助都将不胜感激。

我们运行的是Spring Integration 2.2.4,我尝试了2.2.6,得到了同样的结果。我们正在使用的公司框架就在该版本上。我们正在尝试让他们更新到最新版本,但这还没有发生。

EN

回答 1

Stack Overflow用户

发布于 2014-07-17 05:40:09

看起来您尝试手动构建一个XML Document并将其发送到<int-xml:validating-filter>

当我使用:

代码语言:javascript
复制
return builder.newDocumentBuilder().parse(
            new InputSource(new StringReader("<greeting><other</greeting>")));

我的结论是:

代码语言:javascript
复制
[Fatal Error] :1:17: Element type "other" must be followed by either attribute specifications, ">" or "/>".

这意味着你甚至不能创建一个Document,并且仍然不能谈论validation

尝试将无效xml的字符串发送到验证器通道。在本例中,我得到:

代码语言:javascript
复制
org.springframework.messaging.MessageHandlingException: org.springframework.xml.validation.XmlValidationException: Could not validate source: Element type "other" must be followed by either attribute specifications, ">" or "/>".; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 17; Element type "other" must be followed by either attribute specifications, ">" or "/>".

这意味着我可以处理来自某个upstrem error-channelMessageHandlingException

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24788511

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档