Class ProtocolHandler

  • All Implemented Interfaces:
    Protocol
    Direct Known Subclasses:
    AsciiProtocolHandler, BinaryProtocolHandler

    public abstract class ProtocolHandler
    extends java.lang.Object
    implements Protocol
    Abstract class for the physical link to the Broker. Subclasses of this class encapsulate the protocol level implementation.
    • Field Detail

      • CLIENT_TYPE_PROPERTY

        public static final java.lang.String CLIENT_TYPE_PROPERTY
        See Also:
        Constant Field Values
      • CLIENT_TYPE_CONNECTION

        public static final java.lang.String CLIENT_TYPE_CONNECTION
        See Also:
        Constant Field Values
      • CLIENT_TYPE_SUBSCRIBER

        public static final java.lang.String CLIENT_TYPE_SUBSCRIBER
        See Also:
        Constant Field Values
      • CLIENT_TYPE_DURABLE_SUBSCRIBER

        public static final java.lang.String CLIENT_TYPE_DURABLE_SUBSCRIBER
        See Also:
        Constant Field Values
      • CLIENT_TYPE_QUEUE

        public static final java.lang.String CLIENT_TYPE_QUEUE
        See Also:
        Constant Field Values
      • CLIENT_TYPE_ADMIN

        public static final java.lang.String CLIENT_TYPE_ADMIN
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_PROPERTY

        public static final java.lang.String MESSAGE_TYPE_PROPERTY
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_QUEUE

        public static final java.lang.String MESSAGE_TYPE_QUEUE
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_TOPIC

        public static final java.lang.String MESSAGE_TYPE_TOPIC
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_TEMPORARY_QUEUE

        public static final java.lang.String MESSAGE_TYPE_TEMPORARY_QUEUE
        See Also:
        Constant Field Values
      • MESSAGE_TYPE_TEMPORARY_TOPIC

        public static final java.lang.String MESSAGE_TYPE_TEMPORARY_TOPIC
        See Also:
        Constant Field Values
      • CONNECTION_APPLICATION

        public static final java.lang.String CONNECTION_APPLICATION
        See Also:
        Constant Field Values
      • SUBSCRIBER_APPLICATION

        public static final java.lang.String SUBSCRIBER_APPLICATION
        See Also:
        Constant Field Values
      • DURABLE_SUBSCRIBER_APPLICATION

        public static final java.lang.String DURABLE_SUBSCRIBER_APPLICATION
        See Also:
        Constant Field Values
      • QUEUE_APPLICATION

        public static final java.lang.String QUEUE_APPLICATION
        See Also:
        Constant Field Values
      • ADMIN_APPLICATION

        public static final java.lang.String ADMIN_APPLICATION
        See Also:
        Constant Field Values
      • _link

        protected Link _link
      • _clientID

        protected java.lang.String _clientID
      • _clientGroup

        protected java.lang.String _clientGroup
      • _clientLicenseID

        protected static java.lang.String _clientLicenseID
      • _buffer

        protected byte[] _buffer
      • _bufferPos

        protected int _bufferPos
      • _bufferEol

        protected int _bufferEol
      • _marshalOutUserData

        protected java.lang.Object _marshalOutUserData
      • _marshalInUserData

        protected java.lang.Object _marshalInUserData
      • _isLoggable

        protected boolean _isLoggable
      • _confirmDelivery

        protected boolean _confirmDelivery
      • _lastResponseFromBroker

        protected volatile long _lastResponseFromBroker
    • Constructor Detail

      • ProtocolHandler

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

        protected ProtocolHandler​(WmConnectionImpl connection,
                                  SSLInfo sslinfo)
                           throws javax.jms.JMSException
        Create a new link to the Broker.
        Parameters:
        connection - the connection to which this link belongs
        Throws:
        javax.jms.JMSException
    • Method Detail

      • connect

        public void connect​(BrokerURL url)
                     throws javax.jms.JMSException
        Start the protocol.
        Throws:
        javax.jms.JMSException - if the protocol could not be started
      • setBrokerURL

        public void setBrokerURL​(BrokerURL url)
      • reconnect

        public void reconnect()
                       throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • markForClosure

        public void markForClosure​(boolean exceptionOccured)
        Marks the connection for closure.
      • disconnect

        public void disconnect()
                        throws javax.jms.JMSException
        Stops the protocol.
        Throws:
        javax.jms.JMSException - if the protocol could not be stopped.
      • isDisconnected

        public boolean isDisconnected()
        Check if the Protocol is already disconnected.
        Returns:
        true if the Protocol is disconnected
      • getClientID

        public java.lang.String getClientID()
        Returns the Broker client ID.
        Returns:
        the Broker client ID
      • getBrokerURL

        public BrokerURL getBrokerURL()
      • createMessage

        protected WmMessageImpl createMessage​(byte[] event,
                                              int offset,
                                              int length,
                                              int deliveryCount,
                                              long sequenceNumber,
                                              int[] subscriptionIDs)
                                       throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • getEncryptionLevel

        public int getEncryptionLevel()
                               throws javax.jms.JMSException
        Returns the encryption level of the link.
        Returns:
        the encryption level
        Throws:
        javax.jms.JMSException - if an error occurs getting the encryption level
      • getServerCertificate

        public java.util.Properties getServerCertificate()
                                                  throws javax.jms.JMSException
        Returns properties of the server certificate. The included property names are: "subjectDn", "issuerDn", "status" "serialNumber", "beginDate", "endDate".
        Returns:
        server certificate properties
        Throws:
        javax.jms.JMSException - if an error occurs getting the server certificate
      • sendWithNoReply

        protected void sendWithNoReply​(Request request)
                                throws javax.jms.JMSException
        Send a request to the Broker but don't wait for a reply.
        Parameters:
        request - the request to send to the Broker
        Throws:
        javax.jms.JMSException - if unable to send the request to the Broker
      • sendWithReply

        protected Reply sendWithReply​(Request request,
                                      int requestID)
                               throws javax.jms.JMSException
        Send a request to the Broker and wait for a reply.
        Parameters:
        request - the request to send to the Broker
        requestID - the request ID
        Returns:
        the Broker reply
        Throws:
        javax.jms.JMSException - if unable to send the request or read the reply
      • sendWithCb

        protected Notification sendWithCb​(Request request,
                                          int requestID,
                                          ReplyCb cb)
                                   throws javax.jms.JMSException
        Send a request to the Broker and process the reply asynchronously.
        Parameters:
        request - the request to send to the Broker
        requestID - the request ID
        cb - the callback to call when the reply is received
        Returns:
        the request notification object
        Throws:
        javax.jms.JMSException - if unable to send the request to the Broker
      • sendWithNoReply

        protected void sendWithNoReply​(Request request,
                                       byte[] data)
                                throws javax.jms.JMSException
        Send a publish request to the Broker but don't wait for a reply.
        Parameters:
        request - the publish request
        data - the message to publish
        Throws:
        javax.jms.JMSException - if unable to publish the message to the Broker
      • sendWithReply

        protected Reply sendWithReply​(Request request,
                                      byte[] data,
                                      int requestID)
                               throws javax.jms.JMSException
        Send a publish request to the Broker and wait for a reply.
        Parameters:
        request - the publish request
        data - the message data to publish
        requestID - the request ID
        Returns:
        the Broker reply
        Throws:
        javax.jms.JMSException - if unable to publish the message or read the reply
      • sendWithNoReply

        protected void sendWithNoReply​(Request request,
                                       byte[][] data)
                                throws javax.jms.JMSException
        Send a publish request to the Broker but don't wait for a reply.
        Parameters:
        request - the publish request
        data - the messages to publish
        Throws:
        javax.jms.JMSException - if unable to publish the messages to the Broker
      • sendWithReply

        protected Reply sendWithReply​(Request request,
                                      byte[][] data,
                                      int requestID)
                               throws javax.jms.JMSException
        Send a publish request to the Broker and wait for a reply.
        Parameters:
        request - the publish request
        data - the messages to publish
        requestID - the request ID
        Returns:
        the Broker reply
        Throws:
        javax.jms.JMSException - if unable to publish the messages or read the reply
      • nextRequestID

        protected int nextRequestID()
        Get the next request ID.
        Returns:
        the next request ID
      • read

        protected int read()
                    throws java.io.IOException,
                           javax.jms.JMSException
        Read data from the link.
        Throws:
        java.io.IOException
        javax.jms.JMSException
      • dispatch

        protected abstract void dispatch()
                                  throws java.io.IOException,
                                         javax.jms.JMSException
        Read Broker replies from the link and dispatch.
        Throws:
        javax.jms.JMSException - if unable to read the link or parse the reply
        java.io.IOException
      • getReconnectReply

        protected abstract Reply getReconnectReply()
      • dispatchReply

        protected void dispatchReply​(Reply reply)
                              throws javax.jms.JMSException
        Dispatch a reply.
        Parameters:
        reply - the reply to dispatch
        Throws:
        javax.jms.JMSException
      • getPosixFromLocale

        protected static java.lang.String getPosixFromLocale​(java.util.Locale locale)
        Converts a Java locale to a POSIX locale.
        Parameters:
        locale - the Java locale
        Returns:
        a POSIX locale
      • handleError

        protected void handleError​(int protocolError)
                            throws javax.jms.JMSException
        Default error handler for replies that are errors.
        Parameters:
        protocolError - the protocol error
        Throws:
        javax.jms.JMSException - based upon the reply's error number
      • acquireSendRequestEventsLock

        public boolean acquireSendRequestEventsLock()
      • releaseSendRequestEventsLock

        public void releaseSendRequestEventsLock()
      • isTransactionCompleted

        public boolean isTransactionCompleted()
      • setTransactionCompleted

        public void setTransactionCompleted​(boolean transactionCompleted)
      • setBrokerInactive

        public void setBrokerInactive​(boolean invokeExceptionListener)
      • processClientLicense

        public void processClientLicense()
                                  throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException