Package com.rabbitmq.client.impl
Class ChannelManager
java.lang.Object
com.rabbitmq.client.impl.ChannelManager
- Direct Known Subclasses:
RecoveryAwareChannelManager
Manages a set of channels, indexed by channel number (
1.._channelMax
).-
Field Summary
FieldsModifier and TypeFieldDescriptionMapping from1.._channelMax
toChannelN
instanceprivate final int
Maximum channel number available on this connection.private final IntAllocator
private int
private static final org.slf4j.Logger
protected final MetricsCollector
private final Object
Monitor for_channelMap
andchannelNumberAllocator
protected final ObservationCollector
private ExecutorService
private final Set
<CountDownLatch> private final ThreadFactory
private final ConsumerWorkService
-
Constructor Summary
ConstructorsConstructorDescriptionChannelManager
(ConsumerWorkService workService, int channelMax) ChannelManager
(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory) ChannelManager
(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector, ObservationCollector observationCollector) -
Method Summary
Modifier and TypeMethodDescriptionprivate ChannelN
addNewChannel
(AMQConnection connection, int channelNumber) createChannel
(AMQConnection connection) createChannel
(AMQConnection connection, int channelNumber) getChannel
(int channelNumber) Looks up a channel on this connection.int
void
handleSignal
(ShutdownSignalException signal) Handle shutdown.protected ChannelN
instantiateChannel
(AMQConnection connection, int channelNumber, ConsumerWorkService workService) void
releaseChannelNumber
(ChannelN channel) Remove the channel from the channel map and free the number for re-use.private void
void
setChannelShutdownTimeout
(int channelShutdownTimeout) Set the shutdown timeout for channels.void
setShutdownExecutor
(ExecutorService shutdownExecutor)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
monitor
Monitor for_channelMap
andchannelNumberAllocator
-
_channelMap
Mapping from1.._channelMax
toChannelN
instance -
channelNumberAllocator
-
workService
-
shutdownSet
-
_channelMax
private final int _channelMaxMaximum channel number available on this connection. -
shutdownExecutor
-
threadFactory
-
channelShutdownTimeout
private int channelShutdownTimeout -
metricsCollector
-
observationCollector
-
-
Constructor Details
-
ChannelManager
-
ChannelManager
-
ChannelManager
public ChannelManager(ConsumerWorkService workService, int channelMax, ThreadFactory threadFactory, MetricsCollector metricsCollector, ObservationCollector observationCollector)
-
-
Method Details
-
getChannelMax
public int getChannelMax() -
getChannel
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:
UnknownChannelException
- if there is no channel with numberchannelNumber
on this connection
-
handleSignal
Handle shutdown. All the managedChannel
s are shutdown.- Parameters:
signal
- reason for shutdown
-
scheduleShutdownProcessing
private void scheduleShutdownProcessing() -
createChannel
- Throws:
IOException
-
createChannel
- Throws:
IOException
-
addNewChannel
-
instantiateChannel
protected ChannelN instantiateChannel(AMQConnection connection, int channelNumber, ConsumerWorkService workService) -
releaseChannelNumber
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
-
setShutdownExecutor
-
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 theshutdownExecutor
property is set. Default toConnectionFactory.DEFAULT_HEARTBEAT
+ 5 % seconds- Parameters:
channelShutdownTimeout
- shutdown timeout in milliseconds
-