Example usage for org.springframework.amqp.rabbit.connection RabbitUtils closeMessageConsumer

List of usage examples for org.springframework.amqp.rabbit.connection RabbitUtils closeMessageConsumer

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.connection RabbitUtils closeMessageConsumer.

Prototype

public static void closeMessageConsumer(Channel channel, Collection<String> consumerTags,
            boolean transactional) 

Source Link

Usage

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

public void stop() {
    cancelled.set(true);//from   w w w  .j  a  v  a2 s .  com
    if (consumer != null && consumer.getChannel() != null && consumer.getConsumerTag() != null
            && !this.cancelReceived.get()) {
        try {
            RabbitUtils.closeMessageConsumer(consumer.getChannel(), consumer.getConsumerTag(), transactional);
        } catch (Exception e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Error closing consumer", e);
            }
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Closing Rabbit Channel: " + channel);
    }
    RabbitUtils.setPhysicalCloseRequired(true);
    // This one never throws exceptions...
    RabbitUtils.closeChannel(channel);
    deliveryTags.clear();
    retryDeliveryTags.clear();
    consumer = null;
}