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

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

Introduction

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

Prototype

public BackOffExecution getBackOffExecution() 

Source Link

Usage

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

private void restart(BlockingQueueConsumer consumer) {
    synchronized (this.consumersMonitor) {
        if (this.consumers != null) {
            try {
                // Need to recycle the channel in this consumer
                consumer.stop();//w w w  . j  av a  2 s  .c o m
                // Ensure consumer counts are correct (another is going
                // to start because of the exception, but
                // we haven't counted down yet)
                this.cancellationLock.release(consumer);
                this.consumers.remove(consumer);
                BlockingQueueConsumer newConsumer = createBlockingQueueConsumer();
                newConsumer.setBackOffExecution(consumer.getBackOffExecution());
                consumer = newConsumer;
                this.consumers.put(consumer, true);
            } catch (RuntimeException e) {
                logger.warn(
                        "Consumer failed irretrievably on restart. " + e.getClass() + ": " + e.getMessage());
                // Re-throw and have it logged properly by the caller.
                throw e;
            }
            this.taskExecutor.execute(new AsyncMessageProcessingConsumer(consumer));
        }
    }
}