@Singleton 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(com.rabbitmq.client.Connection connection,
Integer maxIdleChannels)
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.
|
void |
returnChannel(com.rabbitmq.client.Channel channel)
Returns a channel to the pool.
|
public DefaultChannelPool(com.rabbitmq.client.Connection connection, @Nullable @Value(value="${rabbitmq.channel-pool.max-idle-channels}") Integer maxIdleChannels)
connection
- The connection to create channels withmaxIdleChannels
- How many idle channels should be kept openpublic 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