【发布时间】:2016-11-22 04:01:30
【问题描述】:
当我在入站网关中使用消息转换器发生转换错误时,我遇到了一种奇怪的行为。下例中的想法是接收 XML 有效负载(或序列化的 java),将它们转换为 java 对象并使用相同的媒体类型进行响应。
鉴于此配置:
<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 中转发(我在其中定义了一个服务激活器来处理异常)。请注意,此处理程序在有效负载转换后运行良好。
<int:service-activator input-channel="errorChannel" ref="exceptionHandlerService"
method="handleException" requires-reply="true" />
我在这里缺少什么?为什么我的错误处理程序没有处理HttpMessageNotReadableException?欢迎任何帮助!
【问题讨论】:
标签: java xml spring jaxb spring-integration