Class SimpleConnection

  • All Implemented Interfaces:
    com.rabbitmq.client.impl.NetworkConnection, java.lang.AutoCloseable, Connection

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

      Constructors 
      Constructor Description
      SimpleConnection​(com.rabbitmq.client.Connection delegate, int closeTimeout)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBlockedListener​(com.rabbitmq.client.BlockedListener listener)
      Add a BlockedListener.
      void close()
      Close this connection and all its channels with the AMQP.REPLY_SUCCESS close code and message 'OK'.
      com.rabbitmq.client.Channel createChannel​(boolean transactional)
      Create a new channel, using an internally allocated channel number.
      java.net.InetAddress getAddress()  
      com.rabbitmq.client.Connection getDelegate()
      Return the underlying RabbitMQ connection.
      java.net.InetAddress getLocalAddress()  
      int getLocalPort()  
      int getPort()  
      boolean isOpen()
      True if the connection is open.
      boolean removeBlockedListener​(com.rabbitmq.client.BlockedListener listener)
      Remove a BlockedListener.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SimpleConnection

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

      • 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 java.lang.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 java.net.InetAddress getLocalAddress()
        Specified by:
        getLocalAddress in interface com.rabbitmq.client.impl.NetworkConnection
      • getAddress

        public java.net.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object