当我的入站网关中使用消息转换器发生转换错误时,我遇到了一个奇怪的行为。下面的例子中的想法是接收XML有效载荷(或序列化的Java),将它们转换为Java对象并使用相同的媒体类型进行响应。入站网关中的HttpMessageConverter错误处理
鉴于这种配置:
<bean id="converterXml" class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />
<bean id="converterSerialized" class="org.springframework.integration.http.converter.SerializingHttpMessageConverter" />
<util:list id="converters">
<ref bean="converterXml" />
<ref bean="converterSerialized" />
</util:list>
<int-http:inbound-gateway id="inboundIntegrationGateway"
view-name="/integration"
message-converters="converters" error-channel="errorChannel"
request-payload-type="MyXmlPojo"
supported-methods="POST" request-channel="inboundIntegration"
path="/services/integration"
reply-timeout="50000">
</int-http:inbound-gateway>
如果无效的XML有效载荷(例如没有结束标记)被提交时,在JAXB XML转换器产生的异常HttpMessageNotReadableException
未在errorChannel转发(其中I所定义的服务激活器来处理异常)。请注意,此处理程序在之后效果良好负载转换。
<int:service-activator input-channel="errorChannel" ref="exceptionHandlerService"
method="handleException" requires-reply="true" />
我在这里错过了什么?为什么我的错误处理程序不能处理HttpMessageNotReadableException
?欢迎任何帮助!
似乎做一些事情的异常现在写的响应。但是这种例外没有转换器。 我现在有一个MessagingException:“无法转换回复:找不到适用于[org.springframework.http.converter.HttpMessageConversionException]类型的HttpMessageConverter'。我发现的唯一解决方案是为这种异常创建特定的转换器。为什么这个异常不包含在'MessageHandlingException'中并发送给我的错误处理程序? –
@angcap,如果指定'view-name','convert-exceptions'不起作用。在这种情况下,''像普通的'@ Controller'一样工作。请参阅'convert-exceptions' XSD属性说明。 –