@EachBean(value=com.rabbitmq.client.Connection.class) public class DefaultChannelPool extends Object implements 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(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. |
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 String name, @Parameter com.rabbitmq.client.Connection connection, @Parameter RabbitConnectionFactoryConfig config)
name
- The pool nameconnection
- The connectionconfig
- The connection factory configpublic String getName()
getName
in interface io.micronaut.core.naming.Named
public com.rabbitmq.client.Channel getChannel() throws IOException
ChannelPool
getChannel
in interface ChannelPool
IOException
- If a channel needed to be created and encountered an errorpublic com.rabbitmq.client.Channel getChannelWithRecoveringDelay(int recoveryAttempts) throws IOException, InterruptedException
ChannelPool
RecoveryDelayHandler
of the connection for this pool.getChannelWithRecoveringDelay
in interface ChannelPool
recoveryAttempts
- the number of recovery attempts so farIOException
- if a channel needed to be created and encountered an errorInterruptedException
- 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 IOException
IOException
- If an error occurred creating the channel@PreDestroy public void close()
close
in interface AutoCloseable