Class WmClusterMessageConsumerImpl

    • Constructor Detail

      • WmClusterMessageConsumerImpl

        protected WmClusterMessageConsumerImpl​(WmSessionImpl session,
                                               WmDestinationImpl destination,
                                               java.lang.String selector,
                                               boolean noLocal)
                                        throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • WmClusterMessageConsumerImpl

        protected WmClusterMessageConsumerImpl​(WmSessionImpl session,
                                               WmDestinationImpl destination,
                                               java.lang.String durableName,
                                               java.lang.String selector,
                                               boolean noLocal)
                                        throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • WmClusterMessageConsumerImpl

        protected WmClusterMessageConsumerImpl​(WmSessionImpl session)
        Default constructor called by subclasses.
    • Method Detail

      • createConsumer

        public javax.jms.MessageConsumer createConsumer​(WmSessionImpl oneSession)
                                                 throws javax.jms.JMSException
        Populates a consumer in each of the cluster's physical session.
        Throws:
        javax.jms.JMSException
      • receive

        public javax.jms.Message receive()
                                  throws javax.jms.JMSException
        Description copied from class: WmMessageConsumerImpl
        Receives the next message produced for this message consumer.

        This call blocks indefinitely until a message is produced or until this message consumer is closed.

        If this receive is done within a transaction, the consumer retains the message until the transaction commits.

        Specified by:
        receive in interface javax.jms.MessageConsumer
        Overrides:
        receive in class WmMessageConsumerImpl
        Returns:
        the next message produced for this message consumer, or null if this message consumer is concurrently closed
        Throws:
        javax.jms.JMSException - if the JMS provider fails to receive the next message due to some internal error.
      • receive

        public javax.jms.Message receive​(long timeout)
                                  throws javax.jms.JMSException
        Description copied from class: WmMessageConsumerImpl
        Receives the next message that arrives within the specified timeout interval.

        This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A timeout of zero never expires, and the call blocks indefinitely.

        Specified by:
        receive in interface javax.jms.MessageConsumer
        Overrides:
        receive in class WmMessageConsumerImpl
        Parameters:
        timeout - the timeout value (in milliseconds)
        Returns:
        the next message produced for this message consumer, or null if the timeout expires or this message consumer is concurrently closed
        Throws:
        javax.jms.JMSException - if the JMS provider fails to receive the next message due to some internal error.
      • receiveNoWait

        public javax.jms.Message receiveNoWait()
                                        throws javax.jms.JMSException
        Description copied from class: WmMessageConsumerImpl
        Receives the next message if one is immediately available.
        Specified by:
        receiveNoWait in interface javax.jms.MessageConsumer
        Overrides:
        receiveNoWait in class WmMessageConsumerImpl
        Returns:
        the next message produced for this message consumer, or null if one is not available
        Throws:
        javax.jms.JMSException - if the JMS provider fails to receive the next message due to some internal error.
      • messageAcknowledge

        public void messageAcknowledge​(WmMessageImpl message,
                                       boolean isUUIDPresent)
                                throws javax.jms.JMSException
        Acknowledges the message based upon the cluster session's acknowledgement mode for all the consumers.
        Parameters:
        message - the message to acknowledge
        Throws:
        javax.jms.JMSException
      • requestEvents

        public void requestEvents​(int max,
                                  boolean synchronous)
                           throws javax.jms.JMSException
        Issue a request for events to the Broker.
        Overrides:
        requestEvents in class WmMessageConsumerImpl
        Parameters:
        max - maximum number of messages to receive from the Broker acknowledge mode, or -1 to acknowledge nothing
        Throws:
        javax.jms.JMSException - if the request could not be sent
      • requestEvents

        @Deprecated
        public void requestEvents​(java.lang.String[] brokerURLs,
                                  int max,
                                  boolean synchronous)
                           throws javax.jms.JMSException
        Deprecated.
        It will be used only if we support dynamic new Broker addition to connection, right now we just close and create new connection
        Issue a request for events to the Broker.
        Parameters:
        max - maximum number of messages to receive from the Broker acknowledge mode, or -1 to acknowledge nothing
        Throws:
        javax.jms.JMSException - if the request could not be sent
      • cancelRequestEvents

        public void cancelRequestEvents()
                                 throws javax.jms.JMSException
        Cancel the pending request for events.
        Overrides:
        cancelRequestEvents in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException - if the pending request cannot be canceled
      • getActiveConsumerSessions

        public java.util.Set<WmSessionImpl> getActiveConsumerSessions()
      • setActiveConsumerSessions

        public void setActiveConsumerSessions​(java.util.Set<WmSessionImpl> sessions)
      • addActiveConsumerSession

        public void addActiveConsumerSession​(WmSessionImpl session)
      • clearActiveConsumerSessions

        public void clearActiveConsumerSessions()
      • getMessageListener

        public javax.jms.MessageListener getMessageListener()
                                                     throws javax.jms.JMSException
        Gets the cluster message consumer's MessageListener.
        Specified by:
        getMessageListener in interface javax.jms.MessageConsumer
        Overrides:
        getMessageListener in class WmMessageConsumerImpl
        Returns:
        the listener for the message consumer, or null if no listener is set
        Throws:
        javax.jms.JMSException - if the JMS provider fails to get the message listener due to some internal error.
        See Also:
        MessageConsumer.setMessageListener(javax.jms.MessageListener)
      • setMessageListener

        public void setMessageListener​(javax.jms.MessageListener listener)
                                throws javax.jms.JMSException
        Sets the cluster message consumer's MessageListener.

        Setting the message listener to null is the equivalent of unsetting the message listener for the message consumer.

        The effect of calling MessageConsumer.setMessageListener while messages are being consumed by an existing listener or the consumer is being used to consume messages synchronously is undefined.

        Specified by:
        setMessageListener in interface javax.jms.MessageConsumer
        Overrides:
        setMessageListener in class WmMessageConsumerImpl
        Parameters:
        listener - the listener to which the messages are to be delivered
        Throws:
        javax.jms.JMSException - if the JMS provider fails to set the message listener due to some internal error.
      • close

        public void close()
                   throws javax.jms.JMSException
        Closes this cluster message consumer.
        Specified by:
        close in interface javax.jms.MessageConsumer
        Specified by:
        close in interface WmMessageConsumer
        Overrides:
        close in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException - if the JMS provider fails to close the consumer due to some internal error.
      • clear

        public void clear()
                   throws javax.jms.JMSException
        Clears all available messages to this cluster consumer from the Brokers.
        Specified by:
        clear in interface WmMessageConsumer
        Overrides:
        clear in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException - if the JMS provider fails to clear the consumer's messages.
      • available

        public long available()
                       throws javax.jms.JMSException
        Gets the number of messages on the Brokers available to the consumer. This is an approximate number in that some of the messages may be expired or don't match the consumer's message selector or are already pre-acknowledged.
        Specified by:
        available in interface WmMessageConsumer
        Overrides:
        available in class WmMessageConsumerImpl
        Returns:
        the number of messages available to the consumer
        Throws:
        javax.jms.JMSException - if the JMS provider fails to get the number of available messages.
      • commit

        public void commit​(WmMessageImpl message)
                    throws javax.jms.JMSException
        Commits a transaction under which the message is received.
        Overrides:
        commit in class WmMessageConsumerImpl
        Parameters:
        message -
        Throws:
        javax.jms.JMSException
      • startLocalTransaction

        public void startLocalTransaction()
                                   throws javax.jms.JMSException
        Starts a local transaction.
        Overrides:
        startLocalTransaction in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException
      • startLocalTransaction

        public void startLocalTransaction​(java.lang.String[] brokerURLs)
                                   throws javax.jms.JMSException
        Starts a local transaction. This method will start the transaction only on the broker URLs which have been specified through the parameters.
        Throws:
        javax.jms.JMSException
      • setTransactionID

        public void setTransactionID​(long transactionID)
                              throws javax.jms.JMSException
        Set the current transaction ID.
        Overrides:
        setTransactionID in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException
      • checkState

        protected void checkState()
                           throws javax.jms.JMSException
        Overrides:
        checkState in class WmMessageConsumerImpl
        Throws:
        javax.jms.JMSException
      • getTransactedSessions

        public java.util.Set<WmSessionImpl> getTransactedSessions()
      • setMessageQueue

        public void setMessageQueue​(WmConsumerQueue queue)
        Added to change the implementation of the WmConsumerQueue to the WmConsumerQueueImpl in case of cluster consumers
        Overrides:
        setMessageQueue in class WmMessageConsumerImpl
        Parameters:
        queue -
      • logClusterConsumers

        public void logClusterConsumers()