Class AsciiProtocolHandler

  • All Implemented Interfaces:
    Protocol
    Direct Known Subclasses:
    AdminProtocolHandler

    public class AsciiProtocolHandler
    extends ProtocolHandler
    An abstract base class for Broker sessions which represent a Broker client.
    • Constructor Detail

      • AsciiProtocolHandler

        public AsciiProtocolHandler​(SSLInfo sslinfo)
                             throws javax.jms.JMSException
        Create a new link to the Broker.
        Throws:
        javax.jms.JMSException
      • AsciiProtocolHandler

        public AsciiProtocolHandler​(WmConnectionImpl connection,
                                    SSLInfo sslinfo)
                             throws javax.jms.JMSException
        Create a new link to the Broker.
        Throws:
        javax.jms.JMSException
    • Method Detail

      • dispatch

        protected void dispatch()
                         throws java.io.IOException,
                                javax.jms.JMSException
        Description copied from class: ProtocolHandler
        Read Broker replies from the link and dispatch.
        Specified by:
        dispatch in class ProtocolHandler
        Throws:
        javax.jms.JMSException - if unable to read the link or parse the reply
        java.io.IOException
      • getUniqueID

        public java.lang.String getUniqueID​(int sessionID)
                                     throws javax.jms.JMSException
        Get a unique identifier from the Broker.
        Returns:
        a unique identifier
        Throws:
        javax.jms.JMSException
      • getAccessLabel

        public short[] getAccessLabel​(int sessionID)
                               throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • getPublishProcessState

        public int getPublishProcessState​(int sessionID)
                                   throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • startTransaction

        public long startTransaction​(int sessionID)
                              throws javax.jms.JMSException
        Start a transaction.
        Returns:
        the transaction ID
        Throws:
        javax.jms.JMSException - if a transaction cannot be started
      • startTransaction

        public long startTransaction​(int sessionID,
                                     int timeout)
                              throws javax.jms.JMSException
        Start a transaction.
        Returns:
        the transaction ID
        Throws:
        javax.jms.JMSException - if a transaction cannot be started
      • startTransaction

        public long startTransaction​(int sessionID,
                                     java.lang.String transactionID,
                                     int timeout,
                                     boolean join)
                              throws javax.jms.JMSException
        Start a transaction.
        Parameters:
        transactionID - the external transaction ID
        timeout - the transaction timeout
        join - true to join an existing transaction
        Returns:
        the transaction ID
        Throws:
        javax.jms.JMSException - if a transaction cannot be started
      • setTransactionID

        public void setTransactionID​(int sessionID,
                                     long transactionID,
                                     java.lang.String externalID)
                              throws javax.jms.JMSException
        Set the transaction ID to an external ID.
        Parameters:
        transactionID - the transaction ID
        externalID - the external ID
        Throws:
        javax.jms.JMSException - if a transaction cannot be started
      • endTransaction

        public void endTransaction​(int sessionID,
                                   long transactionID,
                                   boolean success)
                            throws javax.jms.JMSException
        End a transaction.
        Parameters:
        transactionID - the transaction ID
        Throws:
        javax.jms.JMSException - if a transaction cannot be started
      • commit

        public void commit​(int sessionID,
                           long transactionID)
                    throws javax.jms.JMSException
        Commit a transaction.
        Parameters:
        transactionID - the transaction ID to commit
        Throws:
        javax.jms.JMSException - if the transaction cannot be committed
      • commit

        public void commit​(int sessionID,
                           java.lang.String transactionID)
                    throws javax.jms.JMSException
        Commit a transaction.
        Parameters:
        transactionID - the transaction ID to commit
        Throws:
        javax.jms.JMSException - if the transaction cannot be committed
      • rollback

        public void rollback​(int sessionID,
                             long transactionID)
                      throws javax.jms.JMSException
        Rollback a transaction.
        Parameters:
        transactionID - the transaction ID to rollback.
        Throws:
        javax.jms.JMSException - if the transaction cannot be rolled back
      • rollback

        public void rollback​(int sessionID,
                             java.lang.String transactionID)
                      throws javax.jms.JMSException
        Rollback a transaction.
        Parameters:
        transactionID - the transaction ID to rollback.
        Throws:
        javax.jms.JMSException - if the transaction cannot be rolled back
      • recover

        public java.lang.String[] recover​(int sessionID,
                                          int flags,
                                          long lastRetrivedTxId)
                                   throws javax.jms.JMSException
        Description copied from interface: Protocol
        Recover the prepared transactions.
        Returns:
        a list of prepared transactions
        Throws:
        javax.jms.JMSException
      • forget

        public void forget​(int sessionID,
                           java.lang.String transactionID)
                    throws javax.jms.JMSException
        Description copied from interface: Protocol
        Forget a transaction.
        transactionID - the XA transaction ID
        Throws:
        javax.jms.JMSException
      • setTransactionTimeout

        public void setTransactionTimeout​(int sessionID,
                                          long transactionID,
                                          int timeout)
                                   throws javax.jms.JMSException
        Description copied from interface: Protocol
        Set the timeout of the transaction specified by transactionID
        Parameters:
        sessionID - the session ID
        transactionID - the transaction ID
        timeout - new timeout value in seconds
        Throws:
        javax.jms.JMSException - if a new timeout cannot be set on a transaction
      • prepare

        public void prepare​(int sessionID,
                            java.lang.String transactionID)
                     throws javax.jms.JMSException
        Description copied from interface: Protocol
        Prepare a transaction.
        transactionID - the XA transaction ID
        Throws:
        javax.jms.JMSException
      • prepare

        public void prepare​(int sessionID,
                            long transactionID)
                     throws javax.jms.JMSException
        Description copied from interface: Protocol
        Prepare a transaction.
        transactionID - the XA transaction ID
        Throws:
        javax.jms.JMSException
      • getQueueLength

        public long getQueueLength​(int sessionID)
                            throws javax.jms.JMSException
        Description copied from interface: Protocol
        Get the queue length.
        Returns:
        the queue length
        Throws:
        javax.jms.JMSException
      • clearQueue

        public void clearQueue​(int sessionID)
                        throws javax.jms.JMSException
        Description copied from interface: Protocol
        Clear the queue.
        Throws:
        javax.jms.JMSException
      • receive

        public Notification receive​(int sessionID,
                                    long transactionID,
                                    int max,
                                    long ack,
                                    boolean synchronous,
                                    ReplyCb cb)
                             throws javax.jms.JMSException
        Send a request to receive messages from the Broker.
        Parameters:
        max - maximum number of messages to receive
        ack - acknowledge through this sequence number, used for DUPS-OK acknowledge mode, or -1 to acknowledge nothing
        cb - the callback to invoke when the messages arrive
        Returns:
        the notification request
        Throws:
        javax.jms.JMSException - if the request cannot be sent
      • cancelReceive

        public void cancelReceive​(int sessionID,
                                  int pendingRequestID)
                           throws javax.jms.JMSException
        Cancel a request to receive messages from the Broker.
        Parameters:
        pendingRequestID - the pending request ID to cancel
        Throws:
        javax.jms.JMSException - if the request cannot be canceled
      • acknowledgeThrough

        public void acknowledgeThrough​(int sessionID,
                                       long transactionID,
                                       long sequenceNumber,
                                       boolean confirm)
                                throws javax.jms.JMSException
        Acknowledge received messages through this sequence number.
        Parameters:
        sequenceNumber - the sequence number to acknowledge through
        Throws:
        javax.jms.JMSException - if the acknowledgement cannot be sent
      • acknowledge

        public void acknowledge​(int sessionID,
                                long transactionID,
                                long sequenceNumber)
                         throws javax.jms.JMSException
        Acknowledge the given message sequence number.
        Parameters:
        sequenceNumber - sequence number to acknowledge
        Throws:
        javax.jms.JMSException - if the acknowledgement cannot be sent
      • acknowledge

        public void acknowledge​(int sessionID,
                                long transactionID,
                                long[] sequenceNumbers)
                         throws javax.jms.JMSException
        Acknowledge the given list of message sequence numbers.
        Parameters:
        sequenceNumbers - list of sequence numbers to acknowledge
        Throws:
        javax.jms.JMSException - if the acknowledgement cannot be sent
      • negativeAcknowledge

        public void negativeAcknowledge​(int sessionID,
                                        long transactionID,
                                        long[] sequenceNumbers)
                                 throws javax.jms.JMSException
        Negative acknowledge the given list of message sequence numbers.
        Parameters:
        sequenceNumbers - list of sequence numbers to negative acknowledge
        Throws:
        javax.jms.JMSException - if the acknowledgement cannot be sent
      • negativeAcknowledge

        public void negativeAcknowledge​(int sessionID,
                                        long transactionID,
                                        long sequenceNumber)
                                 throws javax.jms.JMSException
        Negative acknowledge the message sequence number.
        Parameters:
        sequenceNumber - sequence number to negative acknowledge
        Throws:
        javax.jms.JMSException - if the acknowledgement cannot be sent
      • destroy

        public void destroy​(int sessionID)
                     throws javax.jms.JMSException
        Destroy the underlying Broker client.
        Throws:
        javax.jms.JMSException - if the request cannot be sent
      • disconnect

        public void disconnect​(int sessionID)
                        throws javax.jms.JMSException
        Disconnect the underlying Broker client.
        Throws:
        javax.jms.JMSException - if the request cannot be sent
      • canSubscribe

        public void canSubscribe​(int sessionID,
                                 java.lang.String name)
                          throws javax.jms.JMSException
        Checks if there are adequate permissions to subscribe.
        Parameters:
        name - the name to check for subscribe permissions
        Throws:
        javax.jms.JMSException - if the request cannot be sent or no subscribe permissions
      • canPublish

        public void canPublish​(int sessionID,
                               java.lang.String name)
                        throws javax.jms.JMSException
        Checks if there are adequate permissions to publish.
        Parameters:
        name - the name to check for publish permissions
        Throws:
        javax.jms.JMSException - if the request cannot be sent or no publish permissions
      • setFilter

        public void setFilter​(int sessionID,
                              java.lang.String filter)
                       throws javax.jms.JMSException
        Set the session's filter.
        Parameters:
        filter - the filter to set for this session
        Throws:
        javax.jms.JMSException - if the session cannot be set
      • subscribe

        public void subscribe​(int sessionID,
                              java.lang.String name,
                              java.lang.String filter,
                              int subID)
                       throws javax.jms.JMSException
        Send a subscription request.
        Parameters:
        name - the subscription
        filter - an optional filter
        subID - subscription ID
        Throws:
        javax.jms.JMSException - if the subscription request fails
      • unsubscribe

        public void unsubscribe​(int sessionID,
                                java.lang.String name,
                                java.lang.String filter)
                         throws javax.jms.JMSException
        Send an unsubscribe request.
        Parameters:
        name - the subscription name
        filter - the filter
        Throws:
        javax.jms.JMSException - if the request fails
      • subscriptions

        public Subscription[] subscriptions​(int sessionID)
                                     throws javax.jms.JMSException
        Get the current subscriptions.
        Returns:
        the current subscriptions
        Throws:
        javax.jms.JMSException - if the request fails
      • publish

        public void publish​(int sessionID,
                            long transactionID,
                            WmMessageImpl message,
                            int deliveryMode,
                            boolean deliver,
                            boolean confirmDelivery)
                     throws javax.jms.JMSException
        Publish a message.
        Parameters:
        message - the message to publish
        Throws:
        javax.jms.JMSException - if the publish fails
      • publish

        public void publish​(int sessionID,
                            long transactionID,
                            WmMessageImpl[] messages,
                            int deliveryMode,
                            boolean deliver,
                            boolean confirmDelivery)
                     throws javax.jms.JMSException
        Publish multiple messages.
        Parameters:
        messages - the messages to publish
        Throws:
        javax.jms.JMSException - if the publish fails
      • publish

        public void publish​(int sessionID,
                            long transactionID,
                            WmMessageImpl message,
                            int deliveryMode,
                            boolean deliver)
                     throws javax.jms.JMSException
        Publish a message.
        Parameters:
        message - the message to publish
        Throws:
        javax.jms.JMSException - if the publish fails
      • publish

        public void publish​(int sessionID,
                            long transactionID,
                            WmMessageImpl[] messages,
                            int deliveryMode,
                            boolean deliver)
                     throws javax.jms.JMSException
        Publish multiple messages.
        Parameters:
        messages - the messages to publish
        Throws:
        javax.jms.JMSException - if the publish fails
      • getBrokerName

        public java.lang.String getBrokerName​(int sessionID)
                                       throws javax.jms.JMSException
        Get the name of the broker.
        Returns:
        The name of the broker.
        Throws:
        javax.jms.JMSException
      • getTerritory

        public java.lang.String getTerritory​(int sessionID)
                                      throws javax.jms.JMSException
        Get the territory
        Returns:
        The name of the territory
        Throws:
        javax.jms.JMSException
      • sendKeepAlive

        public void sendKeepAlive​(int sessionID)
                           throws javax.jms.JMSException
        Send a keep-alive to the Broker.
        Throws:
        javax.jms.JMSException - if the request cannot be sent or a reponse was not received within the timeout
      • initializeSession

        public int initializeSession​(java.lang.String clientName,
                                     boolean queue,
                                     boolean priorityOrdering,
                                     java.lang.String clientGroup,
                                     java.lang.String application,
                                     boolean guaranteed,
                                     boolean ackNonPersistent,
                                     boolean sharedState,
                                     int sharedStateOrdering,
                                     boolean reconnect,
                                     boolean acceptExisting)
                              throws javax.jms.JMSException
        Initialize the session.
        Parameters:
        clientName - the Broker client ID
        clientGroup - the client group
        application - the application
        sharedState - true if shared state
        sharedStateOrdering - true if shared state is publish order
        reconnect - true if the session should reconnect to an existing session
        Throws:
        javax.jms.JMSException - if the session cannot be initialized
      • initializeConnection

        public int initializeConnection​(java.lang.String clientName,
                                        java.lang.String clientGroup,
                                        java.lang.String application,
                                        boolean sharedState,
                                        boolean reconnect)
                                 throws javax.jms.JMSException
        Initialize the connection.
        Parameters:
        clientName - the Broker client ID
        clientGroup - the client group
        application - the application
        Throws:
        javax.jms.JMSException - if the session cannot be initialized
      • initializeConnection

        public int initializeConnection​(java.lang.String clientName,
                                        java.lang.String clientGroup,
                                        java.lang.String application,
                                        boolean sharedState,
                                        boolean reconnect,
                                        java.lang.String user,
                                        java.lang.String password)
                                 throws javax.jms.JMSException
        Initialize the connection.
        Parameters:
        clientName - the Broker client ID
        clientGroup - the client group
        application - the application
        Throws:
        javax.jms.JMSException - if the session cannot be initialized
      • setInfo

        public void setInfo​(int sessionID,
                            java.lang.String clientType)
                     throws javax.jms.JMSException
        Description copied from interface: Protocol
        Set the client's infoset.
        clientType - the type of client
        Throws:
        javax.jms.JMSException
      • sendKeepAliveResponse

        public void sendKeepAliveResponse()
                                   throws javax.jms.JMSException
        Send a keep-alive reply to a Broker keep-alive request.
        Throws:
        javax.jms.JMSException - if the reply cannot be sent
      • beginBrowse

        public int beginBrowse​(int sessionID,
                               java.lang.String clientID)
                        throws javax.jms.JMSException
        Begin browse operations.
        Parameters:
        clientID - the client to browse
        Throws:
        javax.jms.JMSException
      • endBrowse

        public void endBrowse​(int sessionID,
                              java.lang.String clientID,
                              int browseID)
                       throws javax.jms.JMSException
        End browse operations.
        Parameters:
        clientID - the client being browsed
        browseID - the browse ID
        Throws:
        javax.jms.JMSException
      • setBrowseFilter

        public void setBrowseFilter​(int sessionID,
                                    java.lang.String clientID,
                                    int browseID,
                                    java.lang.String filter)
                             throws javax.jms.JMSException
        Set the browse filter.
        Parameters:
        clientID - the client to browse
        browseID - the browse ID
        filter - the browse filter
        Throws:
        javax.jms.JMSException
      • browse

        public WmMessageImpl browse​(int sessionID,
                                    java.lang.String clientID,
                                    int browseID)
                             throws javax.jms.JMSException
        Browse the client's messages.
        Parameters:
        clientID - the client to browse
        browseID - the browse ID
        Throws:
        javax.jms.JMSException
      • parseNameList

        protected java.lang.String[] parseNameList​(java.lang.String nameList)
                                            throws javax.jms.JMSException
        Parse a name list from a reply "# name1 name2"
        Throws:
        javax.jms.JMSException