我从队列中提取数据,然后使用int xml:validing filter验证输入有效负载。我设置了在拒绝时抛出异常="true",以便抛出异常。
我需要掌握异常消息(验证错误)以及输入有效负载。你能建议一下可以用来获取这些数据的选项吗?
<int-jms:message-driven-channel-adapter id="jmsIn"
destination="requestQueue" channel="orderChannel"/>
<int-xml:validating-filter id="validatingFilter"
input-channel="orderChannel"
output-channel="validOutputChannel"
discard-channel="errOutputChannel"
schema-type="xml-schema"
throw-exception-on-rejection="true"
schema-location="OrderProcessing/order.xsd"/>
如果您能捕捉到该异常,您的担忧还不清楚。
XmlValidatingMessageSelector
中的代码看起来像:
if (this.throwExceptionOnRejection) {
throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
new AggregatedXmlMessageValidationException(
Arrays.<Throwable>asList(validationExceptions)));
}
因此,MessageRejectedException
具有所需的message
作为验证失败的原因。并且所有的验证错误都表示在该MessageRejectedException
的AggregatedXmlMessageValidationException
cause
中。