Package com.rabbitmq.client.impl
Class ChannelManager
- java.lang.Object
-
- com.rabbitmq.client.impl.ChannelManager
-
- Direct Known Subclasses:
RecoveryAwareChannelManager
public class ChannelManager extends Object
Manages a set of channels, indexed by channel number (1.._channelMax).
-
-
Field Summary
Fields Modifier and Type Field Description protected MetricsCollectormetricsCollector
-
Constructor Summary
Constructors Constructor Description ChannelManager(ConsumerWorkService workService, int channelMax)ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory)ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChannelNcreateChannel(AMQConnection connection)ChannelNcreateChannel(AMQConnection connection, int channelNumber)ChannelNgetChannel(int channelNumber)Looks up a channel on this connection.intgetChannelMax()ExecutorServicegetShutdownExecutor()voidhandleSignal(ShutdownSignalException signal)Handle shutdown.protected ChannelNinstantiateChannel(AMQConnection connection, int channelNumber, ConsumerWorkService workService)voidreleaseChannelNumber(ChannelN channel)Remove the channel from the channel map and free the number for re-use.voidsetChannelShutdownTimeout(int channelShutdownTimeout)Set the shutdown timeout for channels.voidsetShutdownExecutor(ExecutorService shutdownExecutor)
-
-
-
Field Detail
-
metricsCollector
protected final MetricsCollector metricsCollector
-
-
Constructor Detail
-
ChannelManager
public ChannelManager(ConsumerWorkService workService, int channelMax)
-
ChannelManager
public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory)
-
ChannelManager
public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector)
-
-
Method Detail
-
getChannelMax
public int getChannelMax()
-
getChannel
public ChannelN getChannel(int channelNumber)
Looks up a channel on this connection.- Parameters:
channelNumber- the number of the required channel- Returns:
- the channel on this connection with number
channelNumber - Throws:
com.rabbitmq.client.impl.UnknownChannelException- if there is no channel with numberchannelNumberon this connection
-
handleSignal
public void handleSignal(ShutdownSignalException signal)
Handle shutdown. All the managedChannels are shutdown.- Parameters:
signal- reason for shutdown
-
createChannel
public ChannelN createChannel(AMQConnection connection) throws IOException
- Throws:
IOException
-
createChannel
public ChannelN createChannel(AMQConnection connection, int channelNumber) throws IOException
- Throws:
IOException
-
instantiateChannel
protected ChannelN instantiateChannel(AMQConnection connection, int channelNumber, ConsumerWorkService workService)
-
releaseChannelNumber
public void releaseChannelNumber(ChannelN channel)
Remove the channel from the channel map and free the number for re-use. This method must be safe to call multiple times on the same channel. If it is not then things go badly wrong.
-
getShutdownExecutor
public ExecutorService getShutdownExecutor()
-
setShutdownExecutor
public void setShutdownExecutor(ExecutorService shutdownExecutor)
-
setChannelShutdownTimeout
public void setChannelShutdownTimeout(int channelShutdownTimeout)
Set the shutdown timeout for channels. This is the amount of time the manager waits for a channel to shutdown before giving up. Works only when theshutdownExecutorproperty is set. Default toConnectionFactory.DEFAULT_HEARTBEAT+ 5 % seconds- Parameters:
channelShutdownTimeout- shutdown timeout in milliseconds
-
-