Example usage for org.springframework.amqp.rabbit.core ChannelCallback doInRabbit

List of usage examples for org.springframework.amqp.rabbit.core ChannelCallback doInRabbit

Introduction

In this page you can find the example usage for org.springframework.amqp.rabbit.core ChannelCallback doInRabbit.

Prototype

@Nullable
T doInRabbit(Channel channel) throws Exception;

Source Link

Document

Execute any number of operations against the supplied RabbitMQ Channel , possibly returning a result.

Usage

From source file:org.kurento.rabbitmq.RabbitTemplate.java

private <T> T doExecute(ChannelCallback<T> action) {
    Assert.notNull(action, "Callback object must not be null");
    RabbitResourceHolder resourceHolder = getTransactionalResourceHolder();
    Channel channel = resourceHolder.getChannel();
    if (this.confirmCallback != null || this.returnCallback != null) {
        addListener(channel);/*from w  w w  . j  a  v  a 2  s . c  o  m*/
    }
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Executing callback on RabbitMQ Channel: " + channel);
        }
        return action.doInRabbit(channel);
    } catch (Exception ex) {
        if (isChannelLocallyTransacted(channel)) {
            resourceHolder.rollbackAll();
        }
        throw convertRabbitAccessException(ex);
    } finally {
        ConnectionFactoryUtils.releaseResources(resourceHolder);
    }
}