Class SimpleConnection

java.lang.Object
org.springframework.amqp.rabbit.connection.SimpleConnection
All Implemented Interfaces:
com.rabbitmq.client.impl.NetworkConnection, AutoCloseable, Connection

public class SimpleConnection extends Object implements Connection, com.rabbitmq.client.impl.NetworkConnection
Simply a Connection.
Since:
1.0
Author:
Dave Syer, Gary Russell, Artem Bilan
  • Constructor Details

    • SimpleConnection

      public SimpleConnection(com.rabbitmq.client.Connection delegate, int closeTimeout)
  • Method Details

    • createChannel

      public com.rabbitmq.client.Channel createChannel(boolean transactional)
      Description copied from interface: Connection
      Create a new channel, using an internally allocated channel number.
      Specified by:
      createChannel in interface Connection
      Parameters:
      transactional - true if the channel should support transactions
      Returns:
      a new channel descriptor, or null if none is available
    • close

      public void close()
      Description copied from interface: Connection
      Close this connection and all its channels with the AMQP.REPLY_SUCCESS close code and message 'OK'. Waits for all the close operations to complete.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Connection
    • isOpen

      public boolean isOpen()
      True if the connection is open.
      Specified by:
      isOpen in interface Connection
      Returns:
      true if the connection is open
      Throws:
      AutoRecoverConnectionNotCurrentlyOpenException - if the connection is an AutorecoveringConnection and is currently closed; this is required to prevent the CachingConnectionFactory from discarding this connection and opening a new one, in which case the "old" connection would eventually be recovered and orphaned - also any consumers belonging to it might be recovered too and the broker will deliver messages to them when there is no code actually running to deal with those messages (when using the SimpleMessageListenerContainer). If we have actually closed the connection (e.g. via CachingConnectionFactory.resetConnection()) this will return false.
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface Connection
      Specified by:
      getLocalPort in interface com.rabbitmq.client.impl.NetworkConnection
      Returns:
      the local port if the underlying connection supports it.
    • addBlockedListener

      public void addBlockedListener(com.rabbitmq.client.BlockedListener listener)
      Description copied from interface: Connection
      Add a BlockedListener.
      Specified by:
      addBlockedListener in interface Connection
      Parameters:
      listener - the listener to add
      See Also:
      • Connection.addBlockedListener(BlockedListener)
    • removeBlockedListener

      public boolean removeBlockedListener(com.rabbitmq.client.BlockedListener listener)
      Description copied from interface: Connection
      Remove a BlockedListener.
      Specified by:
      removeBlockedListener in interface Connection
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was found and removed, false otherwise
      See Also:
      • Connection.removeBlockedListener(BlockedListener)
    • getLocalAddress

      public InetAddress getLocalAddress()
      Specified by:
      getLocalAddress in interface com.rabbitmq.client.impl.NetworkConnection
    • getAddress

      public InetAddress getAddress()
      Specified by:
      getAddress in interface com.rabbitmq.client.impl.NetworkConnection
    • getPort

      public int getPort()
      Specified by:
      getPort in interface com.rabbitmq.client.impl.NetworkConnection
    • getDelegate

      public com.rabbitmq.client.Connection getDelegate()
      Description copied from interface: Connection
      Return the underlying RabbitMQ connection.
      Specified by:
      getDelegate in interface Connection
      Returns:
      the connection.
    • toString

      public String toString()
      Overrides:
      toString in class Object