Search in sources :

Example 1 with MessagingExceptionWrapper

use of org.springframework.integration.support.MessagingExceptionWrapper in project spring-integration by spring-projects.

the class AbstractPollingEndpoint method doPoll.

private boolean doPoll() {
    IntegrationResourceHolder holder = this.bindResourceHolderIfNecessary(this.getResourceKey(), this.getResourceToBind());
    Message<?> message = null;
    try {
        message = this.receiveMessage();
    } catch (Exception e) {
        if (Thread.interrupted()) {
            if (logger.isDebugEnabled()) {
                logger.debug("Poll interrupted - during stop()? : " + e.getMessage());
            }
            return false;
        } else {
            throw (RuntimeException) e;
        }
    }
    boolean result;
    if (message == null) {
        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Received no Message during the poll, returning 'false'");
        }
        result = false;
    } else {
        if (this.logger.isDebugEnabled()) {
            this.logger.debug("Poll resulted in Message: " + message);
        }
        if (holder != null) {
            holder.setMessage(message);
        }
        try {
            this.handleMessage(message);
        } catch (Exception e) {
            if (e instanceof MessagingException) {
                throw new MessagingExceptionWrapper(message, (MessagingException) e);
            } else {
                throw new MessagingException(message, e);
            }
        }
        result = true;
    }
    return result;
}
Also used : MessagingException(org.springframework.messaging.MessagingException) IntegrationResourceHolder(org.springframework.integration.transaction.IntegrationResourceHolder) MessagingExceptionWrapper(org.springframework.integration.support.MessagingExceptionWrapper) MessagingException(org.springframework.messaging.MessagingException) BeanInitializationException(org.springframework.beans.factory.BeanInitializationException)

Aggregations

BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 MessagingExceptionWrapper (org.springframework.integration.support.MessagingExceptionWrapper)1 IntegrationResourceHolder (org.springframework.integration.transaction.IntegrationResourceHolder)1 MessagingException (org.springframework.messaging.MessagingException)1