Example usage for org.springframework.integration MessageRejectedException MessageRejectedException

List of usage examples for org.springframework.integration MessageRejectedException MessageRejectedException

Introduction

In this page you can find the example usage for org.springframework.integration MessageRejectedException MessageRejectedException.

Prototype

public MessageRejectedException(Message<?> failedMessage, String description, Throwable cause) 

Source Link

Usage

From source file:biz.c24.io.spring.integration.selector.C24ValidatingMessageSelector.java

boolean validateFailFast(ComplexDataObject cdo, Message<?> message) {

    ValidationManager manager = new ValidationManager();

    boolean isValid = false;
    try {/* ww w.ja  va  2s.c o  m*/
        manager.validateByException(cdo);
        isValid = true;
    } catch (ValidationException ve) {
        if (throwExceptionOnRejection) {
            throw new MessageRejectedException(message, "Validation failed.", ve);
        }
    }

    return isValid;

}

From source file:org.springframework.integration.xml.selector.XmlValidatingMessageSelector.java

@SuppressWarnings("unchecked")
public boolean accept(Message<?> message) {
    SAXParseException[] validationExceptions = null;
    try {/*w  ww .j a va 2  s .  c  o m*/
        validationExceptions = this.xmlValidator.validate(this.converter.convertToSource(message.getPayload()));
    } catch (Exception e) {
        throw new MessageHandlingException(message, e);
    }
    boolean validationSuccess = ObjectUtils.isEmpty(validationExceptions);
    if (!validationSuccess) {
        if (this.throwExceptionOnRejection) {
            throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors",
                    new AggregatedXmlMessageValidationException(
                            CollectionUtils.arrayToList(validationExceptions)));
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Message was rejected due to XML Validation errors");
        }
    }
    return validationSuccess;
}