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.NamedA pool ofChannels 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
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_RECOVERY_DELAYThe default delay to apply for recovery channel getter.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description com.rabbitmq.client.ChannelgetChannel()Retrieves a channel from the pool.default com.rabbitmq.client.ChannelgetChannelWithRecoveringDelay(int recoveryAttempts)Retrieves a channel from the pool after blocking the thread for a delay period defined by theRecoveryDelayHandlerof the connection for this pool.default booleanisTopologyRecoveryEnabled()Returns whethertopology recoveryis enabled for the connection of this pool.voidreturnChannel(com.rabbitmq.client.Channel channel)Returns a channel to the pool.
-
-
-
Field Detail
-
DEFAULT_RECOVERY_DELAY
static final int DEFAULT_RECOVERY_DELAY
The default delay to apply for recovery channel getter.- See Also:
- Constant Field Values
-
-
Method Detail
-
getChannel
com.rabbitmq.client.Channel getChannel() throws java.io.IOExceptionRetrieves a channel from the pool. The channel must be returned to the pool after it is no longer being used.- Returns:
- The channel
- Throws:
java.io.IOException- If a channel needed to be created and encountered an error
-
getChannelWithRecoveringDelay
default com.rabbitmq.client.Channel getChannelWithRecoveringDelay(int recoveryAttempts) throws java.io.IOException, java.lang.InterruptedExceptionRetrieves a channel from the pool after blocking the thread for a delay period defined by theRecoveryDelayHandlerof the connection for this pool.- Parameters:
recoveryAttempts- the number of recovery attempts so far- Returns:
- a channel from the pool
- Throws:
java.io.IOException- if a channel needed to be created and encountered an errorjava.lang.InterruptedException- if the thread was interrupted during the delay period
-
isTopologyRecoveryEnabled
default boolean isTopologyRecoveryEnabled()
Returns whethertopology recoveryis 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
-
-