Class DefaultChannelPool

All Implemented Interfaces:
io.micronaut.core.naming.Named, ChannelPool, AutoCloseable

@EachBean(com.rabbitmq.client.Connection.class) public class DefaultChannelPool extends Object implements AutoCloseable, ChannelPool
Default implementation of ChannelPool. There is no limit to the number of channels that can be created. If the channel list is empty a new channel will be created and returned. The maximum number of channels should be the maximum number of concurrent operations.
James Kleeh
  • Constructor Details

    • DefaultChannelPool

      public DefaultChannelPool(@Parameter String name, @Parameter com.rabbitmq.client.Connection connection, @Parameter RabbitConnectionFactoryConfig config)
      Default constructor.
      name - The pool name
      connection - The connection
      config - The connection factory config
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface io.micronaut.core.naming.Named
    • getChannel

      public com.rabbitmq.client.Channel getChannel() throws IOException
      Description copied from interface: ChannelPool
      Retrieves a channel from the pool. The channel must be returned to the pool after it is no longer being used.
      Specified by:
      getChannel in interface ChannelPool
      The channel
      IOException - If a channel needed to be created and encountered an error
    • getChannelWithRecoveringDelay

      public com.rabbitmq.client.Channel getChannelWithRecoveringDelay(int recoveryAttempts) throws IOException, InterruptedException
      Description copied from interface: ChannelPool
      Retrieves a channel from the pool after blocking the thread for a delay period defined by the RecoveryDelayHandler of the connection for this pool.
      Specified by:
      getChannelWithRecoveringDelay in interface ChannelPool
      recoveryAttempts - the number of recovery attempts so far
      a channel from the pool
      IOException - if a channel needed to be created and encountered an error
      InterruptedException - if the thread was interrupted during the delay period
    • isTopologyRecoveryEnabled

      public boolean isTopologyRecoveryEnabled()
      Description copied from interface: ChannelPool
      Returns whether topology recovery is enabled for the connection of this pool.
      Specified by:
      isTopologyRecoveryEnabled in interface ChannelPool
      true by default
    • returnChannel

      public void returnChannel(com.rabbitmq.client.Channel channel)
      Description copied from interface: ChannelPool
      Returns a channel to the pool. No further use of the channel is allowed by the returner.
      Specified by:
      returnChannel in interface ChannelPool
      channel - The channel
    • createChannel

      protected com.rabbitmq.client.Channel createChannel() throws IOException
      Creates a channel.
      The newly created channel
      IOException - If an error occurred creating the channel
    • close

      @PreDestroy public void close()
      Specified by:
      close in interface AutoCloseable