Class RabbitResourceHolder
- java.lang.Object
-
- org.springframework.transaction.support.ResourceHolderSupport
-
- org.springframework.amqp.rabbit.connection.RabbitResourceHolder
-
- All Implemented Interfaces:
org.springframework.transaction.support.ResourceHolder
public class RabbitResourceHolder extends org.springframework.transaction.support.ResourceHolderSupportRabbit resource holder, wrapping a RabbitMQ Connection and Channel. RabbitTransactionManager binds instances of this class to the thread, for a given Rabbit ConnectionFactory.Note: This is an SPI class, not intended to be used by applications.
- See Also:
RabbitTransactionManager,RabbitTemplate
-
-
Constructor Summary
Constructors Constructor Description RabbitResourceHolder()Create a new RabbitResourceHolder that is open for resources to be added.RabbitResourceHolder(com.rabbitmq.client.Channel channel, boolean releaseAfterCompletion)Construct an instance for the channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChannel(com.rabbitmq.client.Channel channel)voidaddChannel(com.rabbitmq.client.Channel channel, Connection connection)voidaddConnection(Connection connection)voidaddDeliveryTag(com.rabbitmq.client.Channel channel, long deliveryTag)voidcloseAll()voidcommitAll()booleancontainsChannel(com.rabbitmq.client.Channel channel)com.rabbitmq.client.ChannelgetChannel()ConnectiongetConnection()booleanisReleaseAfterCompletion()Whether the resources should be released after transaction completion.voidrollbackAll()voidsetRequeueOnRollback(boolean requeueOnRollback)Set to true to requeue a message on rollback; default true.-
Methods inherited from class org.springframework.transaction.support.ResourceHolderSupport
clear, getDeadline, getTimeToLiveInMillis, getTimeToLiveInSeconds, hasTimeout, isOpen, isRollbackOnly, isSynchronizedWithTransaction, isVoid, released, requested, reset, resetRollbackOnly, setRollbackOnly, setSynchronizedWithTransaction, setTimeoutInMillis, setTimeoutInSeconds, unbound
-
-
-
-
Constructor Detail
-
RabbitResourceHolder
public RabbitResourceHolder()
Create a new RabbitResourceHolder that is open for resources to be added.
-
RabbitResourceHolder
public RabbitResourceHolder(com.rabbitmq.client.Channel channel, boolean releaseAfterCompletion)Construct an instance for the channel.- Parameters:
channel- a channel to addreleaseAfterCompletion- true if the channel should be released after completion.
-
-
Method Detail
-
isReleaseAfterCompletion
public boolean isReleaseAfterCompletion()
Whether the resources should be released after transaction completion. Default true. Listener containers set to false because the listener continues to use the channel.- Returns:
- true if the resources should be released.
-
setRequeueOnRollback
public void setRequeueOnRollback(boolean requeueOnRollback)
Set to true to requeue a message on rollback; default true.- Parameters:
requeueOnRollback- true to requeue- Since:
- 1.7.1
-
addConnection
public final void addConnection(Connection connection)
-
addChannel
public final void addChannel(com.rabbitmq.client.Channel channel)
-
addChannel
public final void addChannel(com.rabbitmq.client.Channel channel, @Nullable Connection connection)
-
containsChannel
public boolean containsChannel(com.rabbitmq.client.Channel channel)
-
getConnection
@Nullable public Connection getConnection()
-
getChannel
@Nullable public com.rabbitmq.client.Channel getChannel()
-
commitAll
public void commitAll() throws org.springframework.amqp.AmqpException- Throws:
org.springframework.amqp.AmqpException
-
closeAll
public void closeAll()
-
addDeliveryTag
public void addDeliveryTag(com.rabbitmq.client.Channel channel, long deliveryTag)
-
rollbackAll
public void rollbackAll()
-
-