@EachBean(value=com.rabbitmq.client.Connection.class) public class DefaultChannelPool extends java.lang.Object implements java.lang.AutoCloseable, ChannelPool
ChannelPool
. There is no limit
to the number of channels that can be created. If the channel list is empty
a new channel will be created and returned. The maximum number of channels
should be the maximum number of concurrent operations.DEFAULT_RECOVERY_DELAY
Constructor and Description |
---|
DefaultChannelPool(java.lang.String name,
com.rabbitmq.client.Connection connection,
RabbitConnectionFactoryConfig config)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected com.rabbitmq.client.Channel |
createChannel()
Creates a channel.
|
com.rabbitmq.client.Channel |
getChannel()
Retrieves a channel from the pool.
|
com.rabbitmq.client.Channel |
getChannelWithRecoveringDelay(int recoveryAttempts)
Retrieves a channel from the pool after blocking the thread for a delay period defined by the
RecoveryDelayHandler
of the connection for this pool. |
java.lang.String |
getName() |
boolean |
isTopologyRecoveryEnabled()
Returns whether
topology recovery
is enabled for the connection of this pool. |
void |
returnChannel(com.rabbitmq.client.Channel channel)
Returns a channel to the pool.
|
public DefaultChannelPool(@Parameter java.lang.String name, @Parameter com.rabbitmq.client.Connection connection, @Parameter RabbitConnectionFactoryConfig config)
name
- The pool nameconnection
- The connectionconfig
- The connection factory configpublic java.lang.String getName()
getName
in interface io.micronaut.core.naming.Named
public com.rabbitmq.client.Channel getChannel() throws java.io.IOException
ChannelPool
getChannel
in interface ChannelPool
java.io.IOException
- If a channel needed to be created and encountered an errorpublic com.rabbitmq.client.Channel getChannelWithRecoveringDelay(int recoveryAttempts) throws java.io.IOException, java.lang.InterruptedException
ChannelPool
RecoveryDelayHandler
of the connection for this pool.getChannelWithRecoveringDelay
in interface ChannelPool
recoveryAttempts
- the number of recovery attempts so farjava.io.IOException
- if a channel needed to be created and encountered an errorjava.lang.InterruptedException
- if the thread was interrupted during the delay periodpublic boolean isTopologyRecoveryEnabled()
ChannelPool
topology recovery
is enabled for the connection of this pool.isTopologyRecoveryEnabled
in interface ChannelPool
public void returnChannel(com.rabbitmq.client.Channel channel)
ChannelPool
returnChannel
in interface ChannelPool
channel
- The channelprotected com.rabbitmq.client.Channel createChannel() throws java.io.IOException
java.io.IOException
- If an error occurred creating the channel@PreDestroy public void close()
close
in interface java.lang.AutoCloseable