Package io.micronaut.rabbitmq.connect
Interface ChannelPool
- All Superinterfaces:
io.micronaut.core.naming.Named
- All Known Implementing Classes:
DefaultChannelPool
public interface ChannelPool
extends io.micronaut.core.naming.Named
A pool of
Channel
s to allow for channels to be shared across
threads but not at the same time. A channel retrieved from the pool should
not be accessible to any other threads until the channel is returned from
the pool.- Since:
- 1.1.0
- Author:
- James Kleeh
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default delay to apply for recovery channel getter. -
Method Summary
Modifier and TypeMethodDescriptioncom.rabbitmq.client.Channel
Retrieves a channel from the pool.default com.rabbitmq.client.Channel
getChannelWithRecoveringDelay
(int recoveryAttempts) Retrieves a channel from the pool after blocking the thread for a delay period defined by theRecoveryDelayHandler
of the connection for this pool.default boolean
Returns whethertopology recovery
is enabled for the connection of this pool.void
returnChannel
(com.rabbitmq.client.Channel channel) Returns a channel to the pool.Methods inherited from interface io.micronaut.core.naming.Named
getName
-
Field Details
-
DEFAULT_RECOVERY_DELAY
static final int DEFAULT_RECOVERY_DELAYThe default delay to apply for recovery channel getter.- See Also:
-
-
Method Details
-
getChannel
Retrieves a channel from the pool. The channel must be returned to the pool after it is no longer being used.- Returns:
- The channel
- Throws:
IOException
- If a channel needed to be created and encountered an error
-
getChannelWithRecoveringDelay
default com.rabbitmq.client.Channel getChannelWithRecoveringDelay(int recoveryAttempts) throws IOException, InterruptedException Retrieves a channel from the pool after blocking the thread for a delay period defined by theRecoveryDelayHandler
of the connection for this pool.- Parameters:
recoveryAttempts
- the number of recovery attempts so far- Returns:
- a channel from the pool
- Throws:
IOException
- if a channel needed to be created and encountered an errorInterruptedException
- if the thread was interrupted during the delay period
-
isTopologyRecoveryEnabled
default boolean isTopologyRecoveryEnabled()Returns whethertopology recovery
is enabled for the connection of this pool.- Returns:
- true by default
-
returnChannel
void returnChannel(com.rabbitmq.client.Channel channel) Returns a channel to the pool. No further use of the channel is allowed by the returner.- Parameters:
channel
- The channel
-