Class ProtonConnection

    • Method Detail

      • open

        public ProtonConnection open()
                              throws EngineStateException
        Description copied from interface: Endpoint
        Open the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives.
        Specified by:
        open in interface Endpoint<Connection>
        Returns:
        this Endpoint instance.
        Throws:
        EngineStateException - if an error occurs opening the Connection or the Engine is shutdown.
      • close

        public ProtonConnection close()
                               throws EngineFailedException
        Description copied from interface: Endpoint
        Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it. If the engine encounters an error writing the performative or the engine is in a failed state from a previous error then this method will throw an exception. If the engine has been shutdown then this method will close out the local end of the Endpoint and clean up any local resources before returning normally.
        Specified by:
        close in interface Endpoint<Connection>
        Returns:
        this Endpoint instance.
        Throws:
        EngineFailedException - if an error occurs closing the end point or the Engine is in a failed state.
      • negotiate

        public Connection negotiate()
        Description copied from interface: Connection
        If not already negotiated this method initiates the AMQP protocol negotiation phase of the connection process sending the AMQPHeader to the remote peer. For a client application this could mean requesting the server to indicate if it supports the version of the protocol this client speaks. In rare cases a server could use this to preemptively send its AMQP header. Once a header is sent the remote should respond with the AMQP Header that indicates what protocol level it supports and if there is a mismatch the the engine will be failed with a error indicating the protocol support was not successfully negotiated. If the engine has a configured SASL layer then by starting the AMQP Header exchange this will implicitly first attempt the SASL authentication step of the connection process.
        Specified by:
        negotiate in interface Connection
        Returns:
        this Connection instance.
      • negotiate

        public Connection negotiate​(EventHandler<AMQPHeader> remoteAMQPHeaderHandler)
        Description copied from interface: Connection
        If not already negotiated this method initiates the AMQP protocol negotiation phase of the connection process sending the AMQPHeader to the remote peer. For a client application this could mean requesting the server to indicate if it supports the version of the protocol this client speaks. In rare cases a server could use this to preemptively send its AMQP header. Once a header is sent the remote should respond with the AMQP Header that indicates what protocol level it supports and if there is a mismatch the the engine will be failed with a error indicating the protocol support was not successfully negotiated. If the engine has a configured SASL layer then by starting the AMQP Header exchange this will implicitly first attempt the SASL authentication step of the connection process. The provided remote AMQP Header handler will be called once the remote sends its AMQP Header to the either preemptively or as a response to offered AMQP Header from this peer, even if that has already happened prior to this call.
        Specified by:
        negotiate in interface Connection
        Parameters:
        remoteAMQPHeaderHandler - Handler to be called when an AMQP Header response has arrived.
        Returns:
        this Connection instance.
      • tick

        public long tick​(long current)
        Description copied from interface: Connection
        Performs a tick operation on the connection which checks that Connection Idle timeout processing is run. This method is a convenience method that delegates the work to the Engine.tick(long) method. It is an error to call this method if Connection.tickAuto(ScheduledExecutorService) was called.
        Specified by:
        tick in interface Connection
        Parameters:
        current - Current time value usually taken from System.nanoTime()
        Returns:
        the absolute deadline in milliseconds to next call tick by/at, or 0 if there is none.
        See Also:
        Engine.tick(long)
      • setContainerId

        public ProtonConnection setContainerId​(java.lang.String containerId)
        Description copied from interface: Connection
        Sets the Container Id to be used when opening this Connection. The container Id can only be modified prior to a call to Endpoint.open(), once the connection has been opened locally an error will be thrown if this method is called.
        Specified by:
        setContainerId in interface Connection
        Parameters:
        containerId - The Container Id used for this end of the Connection.
        Returns:
        this connection.
      • getContainerId

        public java.lang.String getContainerId()
        Specified by:
        getContainerId in interface Connection
        Returns:
        the Container ID assigned to this Connection
      • setHostname

        public ProtonConnection setHostname​(java.lang.String hostname)
        Description copied from interface: Connection
        Set the name of the host (either fully qualified or relative) to which this connection is connecting to. This information may be used by the remote peer to determine the correct back-end service to connect the client to. This value will be sent in the Open performative. Note that it is illegal to set the host name to a numeric IP address or include a port number. The host name value can only be modified prior to a call to Endpoint.open(), once the connection has been opened locally an error will be thrown if this method is called.
        Specified by:
        setHostname in interface Connection
        Parameters:
        hostname - the RFC1035 compliant host name.
        Returns:
        this connection.
      • setMaxFrameSize

        public Connection setMaxFrameSize​(long maxFrameSize)
        Description copied from interface: Connection
        Sets the maximum frame size allowed for this connection, which is the largest single frame that the remote can send to this Connection before it will close the connection with an error condition indicating the violation. The legal range for this value is defined as (512 - 2^32-1) bytes. The max frame size value can only be modified prior to a call to Endpoint.open(), once the connection has been opened locally an error will be thrown if this method is called.
        Specified by:
        setMaxFrameSize in interface Connection
        Parameters:
        maxFrameSize - The maximum number of bytes allowed for a single
        Returns:
        this connection.
      • getMaxFrameSize

        public long getMaxFrameSize()
        Specified by:
        getMaxFrameSize in interface Connection
        Returns:
        the currently configured max frame size this connection will accept.
      • setChannelMax

        public ProtonConnection setChannelMax​(int channelMax)
        Description copied from interface: Connection
        Set the channel max value for this Connection. The channel max value can only be modified prior to a call to Endpoint.open(), once the connection has been opened locally an error will be thrown if this method is called.
        Specified by:
        setChannelMax in interface Connection
        Parameters:
        channelMax - The value to set for channel max when opening the connection.
        Returns:
        this connection.
      • setIdleTimeout

        public ProtonConnection setIdleTimeout​(long idleTimeout)
        Description copied from interface: Connection
        Set the idle timeout value for this Connection. The idle timeout value can only be modified prior to a call to Endpoint.open(), once the connection has been opened locally an error will be thrown if this method is called.
        Specified by:
        setIdleTimeout in interface Connection
        Parameters:
        idleTimeout - The value to set for the idle timeout when opening the connection.
        Returns:
        this connection.
      • setOfferedCapabilities

        public ProtonConnection setOfferedCapabilities​(Symbol... capabilities)
        Description copied from interface: Endpoint
        Sets the capabilities to be offered on to the remote when this Endpoint is opened. The offered capabilities value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setOfferedCapabilities in interface Endpoint<Connection>
        Parameters:
        capabilities - The capabilities to be offered to the remote when the Endpoint is opened.
        Returns:
        this Endpoint instance.
      • setDesiredCapabilities

        public ProtonConnection setDesiredCapabilities​(Symbol... capabilities)
        Description copied from interface: Endpoint
        Sets the capabilities that are desired from the remote when this Endpoint is opened. The desired capabilities value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setDesiredCapabilities in interface Endpoint<Connection>
        Parameters:
        capabilities - The capabilities desired from the remote when the Endpoint is opened.
        Returns:
        this Endpoint instance.
      • getDesiredCapabilities

        public Symbol[] getDesiredCapabilities()
        Specified by:
        getDesiredCapabilities in interface Endpoint<Connection>
        Returns:
        the configured desired capabilities that are sent to the remote when the Connection is opened.
      • setProperties

        public ProtonConnection setProperties​(java.util.Map<Symbol,​java.lang.Object> properties)
        Description copied from interface: Endpoint
        Sets the properties to be sent to the remote when this Endpoint is Opened. The Endpoint properties value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setProperties in interface Endpoint<Connection>
        Parameters:
        properties - The properties that will be sent to the remote when this Connection is opened.
        Returns:
        this Endpoint instance.
      • getProperties

        public java.util.Map<Symbol,​java.lang.Object> getProperties()
        Specified by:
        getProperties in interface Endpoint<Connection>
        Returns:
        the configured properties sent to the remote when this Connection is opened.
      • getRemoteContainerId

        public java.lang.String getRemoteContainerId()
        Specified by:
        getRemoteContainerId in interface Connection
        Returns:
        the Container Id assigned to the remote end of the Connection.
      • getRemoteHostname

        public java.lang.String getRemoteHostname()
        Specified by:
        getRemoteHostname in interface Connection
        Returns:
        the host name assigned to the remote end of this Connection.
      • getRemoteMaxFrameSize

        public long getRemoteMaxFrameSize()
        Specified by:
        getRemoteMaxFrameSize in interface Connection
        Returns:
        the remote set max frame size limit.
      • getRemoteIdleTimeout

        public long getRemoteIdleTimeout()
        Specified by:
        getRemoteIdleTimeout in interface Connection
        Returns:
        the idle timeout value provided by the remote end of this Connection.
      • session

        public ProtonSession session()
                              throws java.lang.IllegalStateException
        Description copied from interface: Connection
        Creates a new Session linked to this Connection
        Specified by:
        session in interface Connection
        Returns:
        a newly created Session linked to this Connection.
        Throws:
        java.lang.IllegalStateException - if the Connection has already been closed.
      • sessions

        public java.util.Set<Session> sessions()
                                        throws java.lang.IllegalStateException
        Description copied from interface: Connection
        Returns an unmodifiable Set of Sessions that are tracked by the Connection. The Session instances returned from this method will be locally or remotely open or both which gives the caller full view of the complete set of known Session instances.
        Specified by:
        sessions in interface Connection
        Returns:
        an unmodifiable Set of Sessions tracked by this Connection.
        Throws:
        java.lang.IllegalStateException
      • sessionOpenHandler

        public ProtonConnection sessionOpenHandler​(EventHandler<Session> remoteSessionOpenEventHandler)
        Description copied from interface: Connection
        Sets a EventHandler for when an AMQP Begin frame is received from the remote peer. Used to process remotely initiated Sessions. Locally initiated sessions have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote Session creation.
        Specified by:
        sessionOpenHandler in interface Connection
        Parameters:
        remoteSessionOpenEventHandler - the EventHandler that will be signaled when a session is remotely opened.
        Returns:
        this connection
      • senderOpenHandler

        public ProtonConnection senderOpenHandler​(EventHandler<Sender> remoteSenderOpenEventHandler)
        Description copied from interface: Connection
        Sets a EventHandler for when an AMQP Attach frame is received from the remote peer for a sending link. Used to process remotely initiated sending link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote Receiver creation. If an event handler for remote sender open is registered on the Session that the link is owned by then that handler will be invoked instead of this one.
        Specified by:
        senderOpenHandler in interface Connection
        Parameters:
        remoteSenderOpenEventHandler - the EventHandler that will be signaled when a sender link is remotely opened.
        Returns:
        this connection
      • receiverOpenHandler

        public ProtonConnection receiverOpenHandler​(EventHandler<Receiver> remoteReceiverOpenEventHandler)
        Description copied from interface: Connection
        Sets a EventHandler for when an AMQP Attach frame is received from the remote peer for a receiving link. Used to process remotely initiated receiving link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote Sender creation. If an event handler for remote receiver open is registered on the Session that the link is owned by then that handler will be invoked instead of this one.
        Specified by:
        receiverOpenHandler in interface Connection
        Parameters:
        remoteReceiverOpenEventHandler - the EventHandler that will be signaled when a receiver link is remotely opened.
        Returns:
        this connection
      • transactionManagerOpenHandler

        public ProtonConnection transactionManagerOpenHandler​(EventHandler<TransactionManager> remoteTxnManagerOpenEventHandler)
        Description copied from interface: Connection
        Sets a EventHandler for when an AMQP Attach frame is received from the remote peer for a transaction coordination link. Used to process remotely initiated transaction manager link. Locally initiated links have their own EventHandler invoked instead. This method is Typically used by servers to listen for remote TransactionController creation. If an event handler for remote TransactionController open is registered on the Session that the link is owned by then that handler will be invoked instead of this one.
        Specified by:
        transactionManagerOpenHandler in interface Connection
        Parameters:
        remoteTxnManagerOpenEventHandler - the EventHandler that will be signaled when a TransactionController link is remotely opened.
        Returns:
        this connection