@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.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.
|
String |
getName() |
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 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