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 Channels 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 int DEFAULT_RECOVERY_DELAY
      The 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.Channel getChannel()
      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 the RecoveryDelayHandler of the connection for this pool.
      default boolean isTopologyRecoveryEnabled()
      Returns whether topology 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 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.IOException
        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:
        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.InterruptedException
        Retrieves a channel from the pool after blocking the thread for a delay period defined by the RecoveryDelayHandler of 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 error
        java.lang.InterruptedException - if the thread was interrupted during the delay period
      • isTopologyRecoveryEnabled

        default boolean isTopologyRecoveryEnabled()
        Returns whether topology 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