Class ConsumerChannelRegistry
java.lang.Object
org.springframework.amqp.rabbit.connection.ConsumerChannelRegistry
Consumers register their primary channels with this class. This is used
to ensure that, when using transactions, the resource holder doesn't
close the primary channel being used by the Consumer.
This was previously in ConnectionFactoryUtils, but it caused a class
tangle with RabbitResourceHolder.
- Since:
- 1.2
- Author:
- Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.rabbitmq.client.Channel
See registerConsumerChannel.static com.rabbitmq.client.Channel
getConsumerChannel
(ConnectionFactory connectionFactory) See registerConsumerChannel.static void
registerConsumerChannel
(com.rabbitmq.client.Channel channel, ConnectionFactory connectionFactory) If a listener container is configured to use a RabbitTransactionManager, the consumer's channel is registered here so that it is used as the bound resource when the transaction actually starts.static void
See registerConsumerChannel.
-
Method Details
-
registerConsumerChannel
public static void registerConsumerChannel(com.rabbitmq.client.Channel channel, ConnectionFactory connectionFactory) If a listener container is configured to use a RabbitTransactionManager, the consumer's channel is registered here so that it is used as the bound resource when the transaction actually starts. It is normally not necessary to use an external transaction manager because local transactions work the same in that the channel is bound to the thread. This is for the case when a user happens to wire in a RabbitTransactionManager.- Parameters:
channel
- The channel to register.connectionFactory
- The connection factory.
-
unRegisterConsumerChannel
public static void unRegisterConsumerChannel()See registerConsumerChannel. This method is called to unregister the channel when the consumer exits. -
getConsumerChannel
See registerConsumerChannel. This method is called to retrieve the channel for this consumer.- Returns:
- The channel.
-
getConsumerChannel
@Nullable public static com.rabbitmq.client.Channel getConsumerChannel(ConnectionFactory connectionFactory) See registerConsumerChannel. This method is called to retrieve the channel for this consumer if the connection factory matches.- Parameters:
connectionFactory
- The connection factory.- Returns:
- The channel.
-