Cisco Java
Cisco Java

Reputation: 233

Catching exceptions when using <int-xml:validating-filter>

I am pulling data from queue and then validating the input payload using int-xml:validating-filter. I have set throw-exception-on-rejection="true" so that exception is thrown.

I need to get hold of the exception message(validation errors) as well as the input payload. Could you please suggest the options available to capture this data?

<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"/>

Upvotes: 1

Views: 421

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121542

You concern isn't clear, if you can catch that exception.

The code in the XmlValidatingMessageSelector looks like:

if (this.throwExceptionOnRejection) {
    throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
            new AggregatedXmlMessageValidationException(
                Arrays.<Throwable>asList(validationExceptions)));
}

So, that MessageRejectedException has the desired message as a cause for validation failure. And all the validation errors are represent in the AggregatedXmlMessageValidationException cause of that MessageRejectedException.

Upvotes: 1

Related Questions