Example usage for org.springframework.amqp.rabbit.listener BlockingQueueConsumer rollbackOnExceptionIfNecessary

List of usage examples for org.springframework.amqp.rabbit.listener BlockingQueueConsumer rollbackOnExceptionIfNecessary

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.listener BlockingQueueConsumer rollbackOnExceptionIfNecessary.

Prototype

public void rollbackOnExceptionIfNecessary(Throwable ex) 

Source Link

Document

Perform a rollback, handling rollback exceptions properly.

Usage

From source file:org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.java

private boolean doReceiveAndExecute(BlockingQueueConsumer consumer) throws Throwable {

    Channel channel = consumer.getChannel();

    for (int i = 0; i < this.txSize; i++) {

        logger.trace("Waiting for message from consumer.");
        Message message = consumer.nextMessage(this.receiveTimeout);
        if (message == null) {
            break;
        }//from   w  ww .  ja v  a 2s. co  m
        try {
            executeListener(channel, message);
        } catch (ImmediateAcknowledgeAmqpException e) {
            break;
        } catch (Throwable ex) { //NOSONAR
            consumer.rollbackOnExceptionIfNecessary(ex);
            throw ex;
        }

    }

    return consumer.commitIfNecessary(isChannelLocallyTransacted(channel));

}