Interface Session

  • All Superinterfaces:
    java.lang.AutoCloseable
    All Known Implementing Classes:
    ClientSession, ClientStreamSession

    public interface Session
    extends java.lang.AutoCloseable
    Session object used to create Sender and Receiver instances.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Session beginTransaction()
      Opens a new transaction scoped to this Session if one is not already active.
      Client client()  
      void close()
      Requests a close of the Session at the remote and waits until the Session has been fully closed or until the configured SessionOptions.closeTimeout() is exceeded.
      void close​(ErrorCondition error)
      Requests a close of the Session at the remote and waits until the Session has been fully closed or until the configured SessionOptions.closeTimeout() is exceeded.
      java.util.concurrent.Future<Session> closeAsync()
      Requests a close of the Session at the remote and returns a Future that will be completed once the session has been remotely closed or an error occurs.
      java.util.concurrent.Future<Session> closeAsync​(ErrorCondition error)
      Requests a close of the Session at the remote and returns a Future that will be completed once the session has been remotely closed or an error occurs.
      Session commitTransaction()
      Commit the currently active transaction in this Session.
      Connection connection()  
      java.lang.String[] desiredCapabilities()
      Returns the desired capabilities that the remote provided upon successfully opening the Session.
      java.lang.String[] offeredCapabilities()
      Returns the offered capabilities that the remote provided upon successfully opening the Session.
      Sender openAnonymousSender()
      Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.
      Sender openAnonymousSender​(SenderOptions senderOptions)
      Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.
      Receiver openDurableReceiver​(java.lang.String address, java.lang.String subscriptionName)
      Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.
      Receiver openDurableReceiver​(java.lang.String address, java.lang.String subscriptionName, ReceiverOptions receiverOptions)
      Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.
      Receiver openDynamicReceiver()
      Creates a dynamic receiver used to consume messages from the given node address.
      Receiver openDynamicReceiver​(java.util.Map<java.lang.String,​java.lang.Object> dynamicNodeProperties)
      Creates a dynamic receiver used to consume messages from the given node address.
      Receiver openDynamicReceiver​(java.util.Map<java.lang.String,​java.lang.Object> dynamicNodeProperties, ReceiverOptions receiverOptions)
      Creates a dynamic receiver used to consume messages from the given node address.
      Receiver openDynamicReceiver​(ReceiverOptions receiverOptions)
      Creates a dynamic receiver used to consume messages from the given node address.
      java.util.concurrent.Future<Session> openFuture()  
      Receiver openReceiver​(java.lang.String address)
      Creates a receiver used to consume messages from the given node address.
      Receiver openReceiver​(java.lang.String address, ReceiverOptions receiverOptions)
      Creates a receiver used to consume messages from the given node address.
      Sender openSender​(java.lang.String address)
      Creates a sender used to send messages to the given node address.
      Sender openSender​(java.lang.String address, SenderOptions senderOptions)
      Creates a sender used to send messages to the given node address.
      java.util.Map<java.lang.String,​java.lang.Object> properties()
      Returns the properties that the remote provided upon successfully opening the Session.
      Session rollbackTransaction()
      Roll back the currently active transaction in this Session.
    • Method Detail

      • openFuture

        java.util.concurrent.Future<Session> openFuture()
        Returns:
        a Future that will be completed when the remote opens this Session.
      • close

        void close()
        Requests a close of the Session at the remote and waits until the Session has been fully closed or until the configured SessionOptions.closeTimeout() is exceeded.
        Specified by:
        close in interface java.lang.AutoCloseable
      • closeAsync

        java.util.concurrent.Future<Session> closeAsync()
        Requests a close of the Session at the remote and returns a Future that will be completed once the session has been remotely closed or an error occurs.
        Returns:
        a Future that will be completed when the remote closes this Session.
      • closeAsync

        java.util.concurrent.Future<Session> closeAsync​(ErrorCondition error)
        Requests a close of the Session at the remote and returns a Future that will be completed once the session has been remotely closed or an error occurs.
        Parameters:
        error - The ErrorCondition to transmit to the remote along with the close operation.
        Returns:
        a Future that will be completed when the remote closes this Session.
      • openReceiver

        Receiver openReceiver​(java.lang.String address)
                       throws ClientException
        Creates a receiver used to consume messages from the given node address.
        Parameters:
        address - The source address to attach the consumer to.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openReceiver

        Receiver openReceiver​(java.lang.String address,
                              ReceiverOptions receiverOptions)
                       throws ClientException
        Creates a receiver used to consume messages from the given node address.
        Parameters:
        address - The source address to attach the consumer to.
        receiverOptions - The options for this receiver.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDurableReceiver

        Receiver openDurableReceiver​(java.lang.String address,
                                     java.lang.String subscriptionName)
                              throws ClientException
        Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.
        Parameters:
        address - The source address to attach the consumer to.
        subscriptionName - The name to give the subscription (link name).
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDurableReceiver

        Receiver openDurableReceiver​(java.lang.String address,
                                     java.lang.String subscriptionName,
                                     ReceiverOptions receiverOptions)
                              throws ClientException
        Creates a receiver used to consume messages from the given node address and configure it such that the remote create a durable node.
        Parameters:
        address - The source address to attach the consumer to.
        subscriptionName - The name to give the subscription (link name).
        receiverOptions - The options for this receiver.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDynamicReceiver

        Receiver openDynamicReceiver()
                              throws ClientException
        Creates a dynamic receiver used to consume messages from the given node address.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDynamicReceiver

        Receiver openDynamicReceiver​(java.util.Map<java.lang.String,​java.lang.Object> dynamicNodeProperties)
                              throws ClientException
        Creates a dynamic receiver used to consume messages from the given node address.
        Parameters:
        dynamicNodeProperties - The dynamic node properties to be applied to the node created by the remote.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDynamicReceiver

        Receiver openDynamicReceiver​(ReceiverOptions receiverOptions)
                              throws ClientException
        Creates a dynamic receiver used to consume messages from the given node address.
        Parameters:
        receiverOptions - The options for this receiver.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openDynamicReceiver

        Receiver openDynamicReceiver​(java.util.Map<java.lang.String,​java.lang.Object> dynamicNodeProperties,
                                     ReceiverOptions receiverOptions)
                              throws ClientException
        Creates a dynamic receiver used to consume messages from the given node address.
        Parameters:
        dynamicNodeProperties - The dynamic node properties to be applied to the node created by the remote.
        receiverOptions - The options for this receiver.
        Returns:
        the newly created Receiver
        Throws:
        ClientException - if an internal error occurs.
      • openSender

        Sender openSender​(java.lang.String address)
                   throws ClientException
        Creates a sender used to send messages to the given node address. If no address (i.e null) is specified then a sender will be established to the 'anonymous relay' and each message must specify its destination address.
        Parameters:
        address - The target address to attach to, or null to attach to the anonymous relay.
        Returns:
        the newly created Sender.
        Throws:
        ClientException - if an internal error occurs.
      • openSender

        Sender openSender​(java.lang.String address,
                          SenderOptions senderOptions)
                   throws ClientException
        Creates a sender used to send messages to the given node address. If no address (i.e null) is specified then a sender will be established to the 'anonymous relay' and each message must specify its destination address.
        Parameters:
        address - The target address to attach to, or null to attach to the anonymous relay.
        senderOptions - The options for this sender.
        Returns:
        the newly created Sender.
        Throws:
        ClientException - if an internal error occurs.
      • openAnonymousSender

        Sender openAnonymousSender()
                            throws ClientException
        Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.
        Returns:
        the newly created Sender.
        Throws:
        ClientException - if an internal error occurs.
        ClientUnsupportedOperationException - if the remote did not signal support for anonymous relays.
      • openAnonymousSender

        Sender openAnonymousSender​(SenderOptions senderOptions)
                            throws ClientException
        Creates a sender that is established to the 'anonymous relay' and as such each message that is sent using this sender must specify an address in its destination address field.
        Parameters:
        senderOptions - The options for this sender.
        Returns:
        the newly created Sender.
        Throws:
        ClientException - if an internal error occurs.
        ClientUnsupportedOperationException - if the remote did not signal support for anonymous relays.
      • properties

        java.util.Map<java.lang.String,​java.lang.Object> properties()
                                                                   throws ClientException
        Returns the properties that the remote provided upon successfully opening the Session. If the open has not completed yet this method will block to await the open response which carries the remote properties. If the remote provides no properties this method will return null.
        Returns:
        any properties provided from the remote once the session has successfully opened.
        Throws:
        ClientException - if an error occurs while obtaining the Session remote properties.
      • offeredCapabilities

        java.lang.String[] offeredCapabilities()
                                        throws ClientException
        Returns the offered capabilities that the remote provided upon successfully opening the Session. If the open has not completed yet this method will block to await the open response which carries the remote offered capabilities. If the remote provides no capabilities this method will return null.
        Returns:
        any capabilities provided from the remote once the session has successfully opened.
        Throws:
        ClientException - if an error occurs while obtaining the Session remote offered capabilities.
      • desiredCapabilities

        java.lang.String[] desiredCapabilities()
                                        throws ClientException
        Returns the desired capabilities that the remote provided upon successfully opening the Session. If the open has not completed yet this method will block to await the open response which carries the remote desired capabilities. If the remote provides no capabilities this method will return null.
        Returns:
        any desired capabilities provided from the remote once the session has successfully opened.
        Throws:
        ClientException - if an error occurs while obtaining the Session remote desired capabilities.
      • beginTransaction

        Session beginTransaction()
                          throws ClientException
        Opens a new transaction scoped to this Session if one is not already active. A Session that has an active transaction will perform all sends and all delivery dispositions under that active transaction. If the user wishes to send with the same session but outside of a transaction they user must commit the active transaction and not request that a new one be started. A session can only have one active transaction at a time and as such any call to begin while there is a currently active transaction will throw an ClientTransactionNotActiveException to indicate that the operation being requested is not valid at that time. This is a blocking method that will return successfully only after a new transaction has been started.
        Returns:
        this Session instance.
        Throws:
        ClientException - if an error occurs while attempting to begin a new transaction.
      • commitTransaction

        Session commitTransaction()
                           throws ClientException
        Commit the currently active transaction in this Session. Commit the currently active transaction in this Session but does not start a new transaction automatically. If there is no current transaction this method will throw an ClientTransactionNotActiveException to indicate this error. If the active transaction has entered an in doubt state or was remotely rolled back this method will throw an error to indicate that the commit failed and that a new transaction need to be started by the user. When a transaction rolled back error occurs the user should assume that all work performed under that transaction has failed and will need to be attempted under a new transaction. This is a blocking method that will return successfully only after the current transaction has been committed.
        Returns:
        this Session instance.
        Throws:
        ClientException - if an error occurs while attempting to commit the current transaction.
      • rollbackTransaction

        Session rollbackTransaction()
                             throws ClientException
        Roll back the currently active transaction in this Session. Roll back the currently active transaction in this Session but does not automatically start a new transaction. If there is no current transaction this method will throw an ClientTransactionNotActiveException to indicate this error. If the active transaction has entered an in doubt state or was remotely rolled back this method will throw an error to indicate that the roll back failed and that a new transaction need to be started by the user.
        Returns:
        this Session instance.
        Throws:
        ClientException - if an error occurs while attempting to roll back the current transaction.