Class ProtonSession

java.lang.Object
org.apache.qpid.protonj2.engine.impl.ProtonEndpoint<Session>
org.apache.qpid.protonj2.engine.impl.ProtonSession
All Implemented Interfaces:
Endpoint<Session>, Session

public class ProtonSession extends ProtonEndpoint<Session> implements Session
Proton API for Session type.
  • Constructor Details

    • ProtonSession

      public ProtonSession(ProtonConnection connection, int localChannel)
      Creates a new ProtonSession instance bound to the given ProtonConnection.
      Parameters:
      connection - The connection that is the parent of the session instance.
      localChannel - The local channel onto which this session is bound.
  • Method Details

    • getConnection

      public ProtonConnection getConnection()
      Specified by:
      getConnection in interface Session
      Returns:
      the parent Connection for this Session.
    • getParent

      public ProtonConnection getParent()
      Description copied from interface: Endpoint
      Gets the parent of this Endpoint which can be itself for Connection instance.
      Specified by:
      getParent in interface Endpoint<Session>
      Specified by:
      getParent in interface Session
      Returns:
      the parent Connection of the Link
    • getLocalChannel

      public int getLocalChannel()
      Returns:
      the local channel onto which this Session is bound.
    • getRemoteChannel

      public int getRemoteChannel()
      Returns:
      the remote channel onto which this Session is bound or -1 if not yet remotely opened.
    • getState

      public SessionState getState()
      Specified by:
      getState in interface Session
      Returns:
      the local session state
    • getRemoteState

      public SessionState getRemoteState()
      Specified by:
      getRemoteState in interface Session
      Returns:
      the remote session state (as last communicated)
    • open

      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<Session>
      Returns:
      this Endpoint instance.
      Throws:
      EngineStateException - if an error occurs opening the Connection or the Engine is shutdown.
      IllegalStateException
    • close

      public ProtonSession 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<Session>
      Returns:
      this Endpoint instance.
      Throws:
      EngineFailedException - if an error occurs closing the end point or the Engine is in a failed state.
    • isLocallyOpen

      public boolean isLocallyOpen()
      Description copied from interface: Endpoint
      Returns true if this Endpoint is currently locally open meaning that the Endpoint.open() has been called but the Endpoint.close() has not.
      Specified by:
      isLocallyOpen in interface Endpoint<Session>
      Returns:
      true if the Endpoint is locally open.
      See Also:
    • isLocallyClosed

      public boolean isLocallyClosed()
      Description copied from interface: Endpoint
      Returns true if this Endpoint is currently locally closed meaning that a call to the Endpoint.close() method has occurred.
      Specified by:
      isLocallyClosed in interface Endpoint<Session>
      Returns:
      true if the Endpoint is locally closed.
      See Also:
    • setIncomingCapacity

      public Session setIncomingCapacity(int incomingCapacity)
      Description copied from interface: Session
      Sets the maximum number of bytes this session can be sent from the remote.
      Specified by:
      setIncomingCapacity in interface Session
      Parameters:
      incomingCapacity - maximum number of incoming bytes this session will allow
      Returns:
      this Session instance.
    • getIncomingCapacity

      public int getIncomingCapacity()
      Specified by:
      getIncomingCapacity in interface Session
      Returns:
      the current incoming capacity of this session.
    • getRemainingIncomingCapacity

      public int getRemainingIncomingCapacity()
      Specified by:
      getRemainingIncomingCapacity in interface Session
      Returns:
      the remaining session capacity based on how many bytes are currently pending,
    • setOutgoingCapacity

      public Session setOutgoingCapacity(int outgoingCapacity)
      Description copied from interface: Session
      Sets the maximum number of bytes this session can be write before blocking additional sends until the written bytes are known to have been flushed to the write. This limit is intended to deal with issues of memory allocation when the I/O layer allows for asynchronous writes and finer grained control over the pending write buffers is needed.
      Specified by:
      setOutgoingCapacity in interface Session
      Parameters:
      outgoingCapacity - maximum number of outgoing bytes this session will allow before stopping senders from sending.
      Returns:
      this Session instance.
    • getOutgoingCapacity

      public int getOutgoingCapacity()
      Specified by:
      getOutgoingCapacity in interface Session
      Returns:
      the current outgoing capacity limit of this session.
    • getRemainingOutgoingCapacity

      public int getRemainingOutgoingCapacity()
      Specified by:
      getRemainingOutgoingCapacity in interface Session
      Returns:
      the remaining session outgoing capacity based on how many bytes are currently pending,
    • setHandleMax

      public Session setHandleMax(long handleMax) throws IllegalStateException
      Description copied from interface: Session
      Set the handle max value for this Session. The handle max value can only be modified prior to a call to Endpoint.open(), once the session has been opened locally an error will be thrown if this method is called.
      Specified by:
      setHandleMax in interface Session
      Parameters:
      handleMax - The value to set for handle max when opening the session.
      Returns:
      this Session instance.
      Throws:
      IllegalStateException - if the Session has already been opened.
    • getHandleMax

      public long getHandleMax()
      Specified by:
      getHandleMax in interface Session
      Returns:
      the currently configured handle max for this Session
    • setProperties

      public ProtonSession setProperties(Map<Symbol,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<Session>
      Parameters:
      properties - The properties that will be sent to the remote when this Connection is opened.
      Returns:
      this Endpoint instance.
    • getProperties

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

      public ProtonSession 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<Session>
      Parameters:
      capabilities - The capabilities to be offered to the remote when the Endpoint is opened.
      Returns:
      this Endpoint instance.
    • getOfferedCapabilities

      public Symbol[] getOfferedCapabilities()
      Specified by:
      getOfferedCapabilities in interface Endpoint<Session>
      Returns:
      the configured capabilities that are offered to the remote when the Endpoint is opened.
    • setDesiredCapabilities

      public ProtonSession 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<Session>
      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<Session>
      Returns:
      the configured desired capabilities that are sent to the remote when the Connection is opened.
    • links

      public Set<Link<?>> links()
      Description copied from interface: Session
      Returns a Set of all Sender and Receiver instances that are being tracked by this Session.
      Specified by:
      links in interface Session
      Returns:
      a set of Sender and Receiver instances tracked by this session.
    • senders

      public Set<ProtonSender> senders()
      Description copied from interface: Session
      Returns a Set of Sender instances that are being tracked by this Session.
      Specified by:
      senders in interface Session
      Returns:
      a set of Sender instances tracked by this session.
    • receivers

      public Set<ProtonReceiver> receivers()
      Description copied from interface: Session
      Returns a Set of Receiver instances that are being tracked by this Session.
      Specified by:
      receivers in interface Session
      Returns:
      a set of Receiver instances tracked by this session.
    • isRemotelyOpen

      public boolean isRemotelyOpen()
      Description copied from interface: Endpoint
      Returns true if this Endpoint is currently remotely open meaning that the AMQP performative that completes the open phase of this Endpoint's lifetime has arrived but the performative that closes it has not.
      Specified by:
      isRemotelyOpen in interface Endpoint<Session>
      Returns:
      true if the Endpoint is remotely open.
      See Also:
    • isRemotelyClosed

      public boolean isRemotelyClosed()
      Description copied from interface: Endpoint
      Returns true if this Endpoint is currently remotely closed meaning that the AMQP performative that completes the close phase of this Endpoint's lifetime has arrived.
      Specified by:
      isRemotelyClosed in interface Endpoint<Session>
      Returns:
      true if the Endpoint is remotely closed.
      See Also:
    • getRemoteOfferedCapabilities

      public Symbol[] getRemoteOfferedCapabilities()
      Specified by:
      getRemoteOfferedCapabilities in interface Endpoint<Session>
      Returns:
      the capabilities offered by the remote when it opened its end of the Endpoint.
    • getRemoteDesiredCapabilities

      public Symbol[] getRemoteDesiredCapabilities()
      Specified by:
      getRemoteDesiredCapabilities in interface Endpoint<Session>
      Returns:
      the capabilities desired by the remote when it opened its end of the Endpoint.
    • getRemoteProperties

      public Map<Symbol,Object> getRemoteProperties()
      Specified by:
      getRemoteProperties in interface Endpoint<Session>
      Returns:
      the properties sent by the remote when it opened its end of the Endpoint.
    • sender

      public ProtonSender sender(String name)
      Description copied from interface: Session
      Create a new Sender link using the provided name.
      Specified by:
      sender in interface Session
      Parameters:
      name - The name to assign to the created Sender
      Returns:
      a newly created Sender instance.
    • receiver

      public ProtonReceiver receiver(String name)
      Description copied from interface: Session
      Create a new Receiver link using the provided name
      Specified by:
      receiver in interface Session
      Parameters:
      name - The name to assign to the created Receiver
      Returns:
      a newly created Receiver instance.
    • coordinator

      public TransactionController coordinator(String name) throws IllegalStateException
      Description copied from interface: Session
      Create a new TransactionController using the provided name.
      Specified by:
      coordinator in interface Session
      Parameters:
      name - The name to assign to the created TransactionController
      Returns:
      a newly created TransactionController instance.
      Throws:
      IllegalStateException - if the Session has already been closed.
    • senderOpenHandler

      public ProtonSession senderOpenHandler(EventHandler<Sender> remoteSenderOpenEventHandler)
      Description copied from interface: Session
      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 this Session for a link scoped to it then this handler will be invoked instead of the variant in the Connection API.
      Specified by:
      senderOpenHandler in interface Session
      Parameters:
      remoteSenderOpenEventHandler - the EventHandler that will be signaled when a sender link is remotely opened.
      Returns:
      this session for chaining
    • receiverOpenHandler

      public ProtonSession receiverOpenHandler(EventHandler<Receiver> remoteReceiverOpenEventHandler)
      Description copied from interface: Session
      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 sender open is registered on this Session for a link scoped to it then this handler will be invoked instead of the variant in the Connection API.
      Specified by:
      receiverOpenHandler in interface Session
      Parameters:
      remoteReceiverOpenEventHandler - the EventHandler that will be signaled when a receiver link is remotely opened.
      Returns:
      this session for chaining
    • transactionManagerOpenHandler

      public ProtonSession transactionManagerOpenHandler(EventHandler<TransactionManager> remoteTxnManagerOpenEventHandler)
      Description copied from interface: Session
      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 this Session for a TransactionController scoped to it then this handler will be invoked instead of the variant in the Connection API.
      Specified by:
      transactionManagerOpenHandler in interface Session
      Parameters:
      remoteTxnManagerOpenEventHandler - the EventHandler that will be signaled when a TransactionController link is remotely opened.
      Returns:
      this Session for chaining
    • deliveryReadHandler

      public ProtonSession deliveryReadHandler(EventHandler<IncomingDelivery> deliveryReadHandler)
      Description copied from interface: Session
      Allows monitoring of incoming deliveries to receivers attached to this Session. The Receiver that is the target of the incoming delivery will be notified first of the incoming delivery and any processing should be done using the Receiver.deliveryReadHandler(EventHandler). This event point will be trigger only after the Receiver level handler and should be used to monitor deliveries passing through a session for logging or other state related actions performed by the service managing this session.
      Specified by:
      deliveryReadHandler in interface Session
      Parameters:
      deliveryReadHandler - The delivery that was read which contains
      Returns:
      this Session for chaining