Example usage for org.springframework.amqp.rabbit.connection RabbitResourceHolder containsChannel

List of usage examples for org.springframework.amqp.rabbit.connection RabbitResourceHolder containsChannel

Introduction

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

Prototype

public boolean containsChannel(Channel channel) 

Source Link

Usage

From source file:org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.java

/**
 * Determine whether the given RabbitMQ Channel is transactional, that is,
 * bound to the current thread by Spring's transaction facilities.
 * /*from  w w  w  .java2 s  .  co m*/
 * @param channel
 *            the RabbitMQ Channel to check
 * @param connectionFactory
 *            the RabbitMQ ConnectionFactory that the Channel originated
 *            from
 * @return whether the Channel is transactional
 */
public static boolean isChannelTransactional(Channel channel, ConnectionFactory connectionFactory) {
    if (channel == null || connectionFactory == null) {
        return false;
    }
    RabbitResourceHolder resourceHolder = (RabbitResourceHolder) TransactionSynchronizationManager
            .getResource(connectionFactory);
    return (resourceHolder != null && resourceHolder.containsChannel(channel));
}