Class AbstractSubscription

java.lang.Object
org.apache.activemq.broker.region.AbstractSubscription
All Implemented Interfaces:
Subscription, SubscriptionRecovery
Direct Known Subclasses:
PrefetchSubscription, TopicSubscription

public abstract class AbstractSubscription extends Object implements Subscription
  • Field Details

    • broker

      protected Broker broker
    • context

      protected ConnectionContext context
    • info

      protected org.apache.activemq.command.ConsumerInfo info
    • destinationFilter

      protected final org.apache.activemq.filter.DestinationFilter destinationFilter
    • destinations

      protected final CopyOnWriteArrayList<Destination> destinations
    • prefetchExtension

      protected final AtomicInteger prefetchExtension
  • Constructor Details

    • AbstractSubscription

      public AbstractSubscription(Broker broker, ConnectionContext context, org.apache.activemq.command.ConsumerInfo info) throws jakarta.jms.InvalidSelectorException
      Throws:
      jakarta.jms.InvalidSelectorException
  • Method Details

    • acknowledge

      public void acknowledge(ConnectionContext context, org.apache.activemq.command.MessageAck ack) throws Exception
      Description copied from interface: Subscription
      Used when client acknowledge receipt of dispatched message.
      Specified by:
      acknowledge in interface Subscription
      Throws:
      IOException
      Exception
    • matches

      public boolean matches(org.apache.activemq.broker.region.MessageReference node, org.apache.activemq.filter.MessageEvaluationContext context) throws IOException
      Description copied from interface: Subscription
      Is the subscription interested in the message?
      Specified by:
      matches in interface Subscription
      Returns:
      true if matching
      Throws:
      IOException
    • isWildcard

      public boolean isWildcard()
      Description copied from interface: Subscription
      Returns true if this subscription is a Wildcard subscription.
      Specified by:
      isWildcard in interface Subscription
      Returns:
      true if wildcard subscription.
    • matches

      public boolean matches(org.apache.activemq.command.ActiveMQDestination destination)
      Description copied from interface: Subscription
      Is the subscription interested in messages in the destination?
      Specified by:
      matches in interface Subscription
      Returns:
      true if matching
    • add

      public void add(ConnectionContext context, Destination destination) throws Exception
      Description copied from interface: Subscription
      The subscription will be receiving messages from the destination.
      Specified by:
      add in interface Subscription
      Throws:
      Exception
    • remove

      public List<org.apache.activemq.broker.region.MessageReference> remove(ConnectionContext context, Destination destination) throws Exception
      Description copied from interface: Subscription
      The subscription will be no longer be receiving messages from the destination.
      Specified by:
      remove in interface Subscription
      Returns:
      a list of un-acked messages that were added to the subscription.
      Throws:
      Exception
    • getConsumerInfo

      public org.apache.activemq.command.ConsumerInfo getConsumerInfo()
      Description copied from interface: Subscription
      The ConsumerInfo object that created the subscription.
      Specified by:
      getConsumerInfo in interface Subscription
    • gc

      public void gc()
      Description copied from interface: Subscription
      The subscription should release as may references as it can to help the garbage collector reclaim memory.
      Specified by:
      gc in interface Subscription
    • getContext

      public ConnectionContext getContext()
      Specified by:
      getContext in interface Subscription
    • getInfo

      public org.apache.activemq.command.ConsumerInfo getInfo()
    • getSelectorExpression

      public org.apache.activemq.filter.BooleanExpression getSelectorExpression()
    • getSelector

      public String getSelector()
      Specified by:
      getSelector in interface Subscription
      Returns:
      the JMS selector on the current subscription
    • setSelector

      public void setSelector(String selector) throws jakarta.jms.InvalidSelectorException
      Description copied from interface: Subscription
      Attempts to change the current active selector on the subscription. This operation is not supported for persistent topics.
      Specified by:
      setSelector in interface Subscription
      Throws:
      jakarta.jms.InvalidSelectorException
    • getObjectName

      public ObjectName getObjectName()
      Specified by:
      getObjectName in interface Subscription
      Returns:
      the JMX object name that this subscription was registered as if applicable
    • setObjectName

      public void setObjectName(ObjectName objectName)
      Description copied from interface: Subscription
      Set when the subscription is registered in JMX
      Specified by:
      setObjectName in interface Subscription
    • getPrefetchSize

      public int getPrefetchSize()
      Specified by:
      getPrefetchSize in interface Subscription
      Returns:
      the prefetch size that is configured for the subscription
    • isUsePrefetchExtension

      public boolean isUsePrefetchExtension()
    • setUsePrefetchExtension

      public void setUsePrefetchExtension(boolean usePrefetchExtension)
    • setPrefetchSize

      public void setPrefetchSize(int newSize)
    • isRecoveryRequired

      public boolean isRecoveryRequired()
      Description copied from interface: Subscription
      Informs the Broker if the subscription needs to intervention to recover it's state e.g. DurableTopicSubscriber may do
      Specified by:
      isRecoveryRequired in interface Subscription
      Returns:
      true if recovery required
      See Also:
    • isSlowConsumer

      public boolean isSlowConsumer()
      Specified by:
      isSlowConsumer in interface Subscription
    • setSlowConsumer

      public void setSlowConsumer(boolean val)
    • addRecoveredMessage

      public boolean addRecoveredMessage(ConnectionContext context, org.apache.activemq.broker.region.MessageReference message) throws Exception
      Description copied from interface: SubscriptionRecovery
      Add a message to the SubscriptionRecovery
      Specified by:
      addRecoveredMessage in interface SubscriptionRecovery
      Returns:
      true if the message is accepted
      Throws:
      Exception
    • getActiveMQDestination

      public org.apache.activemq.command.ActiveMQDestination getActiveMQDestination()
      Specified by:
      getActiveMQDestination in interface SubscriptionRecovery
      Returns:
      the Destination associated with this Subscription
    • isBrowser

      public boolean isBrowser()
      Specified by:
      isBrowser in interface Subscription
      Returns:
      true if a browser
    • getInFlightMessageSize

      public long getInFlightMessageSize()
      Specified by:
      getInFlightMessageSize in interface Subscription
      Returns:
      the size in bytes of the messages awaiting acknowledgement
    • getInFlightUsage

      public int getInFlightUsage()
      Specified by:
      getInFlightUsage in interface Subscription
      Returns:
      the in flight messages as a percentage of the prefetch size
    • addDestination

      public void addDestination(Destination destination)
      Add a destination
      Parameters:
      destination -
    • removeDestination

      public void removeDestination(Destination destination)
      Remove a destination
      Parameters:
      destination -
    • getCursorMemoryHighWaterMark

      public int getCursorMemoryHighWaterMark()
      Specified by:
      getCursorMemoryHighWaterMark in interface Subscription
    • setCursorMemoryHighWaterMark

      public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
      Specified by:
      setCursorMemoryHighWaterMark in interface Subscription
    • countBeforeFull

      public int countBeforeFull()
      Specified by:
      countBeforeFull in interface Subscription
      Returns:
      the number of messages this subscription can accept before its full
    • unmatched

      public void unmatched(org.apache.activemq.broker.region.MessageReference node) throws IOException
      Specified by:
      unmatched in interface Subscription
      Throws:
      IOException
    • doAddRecoveredMessage

      protected void doAddRecoveredMessage(org.apache.activemq.broker.region.MessageReference message) throws Exception
      Throws:
      Exception
    • getTimeOfLastMessageAck

      public long getTimeOfLastMessageAck()
      Description copied from interface: Subscription
      Returns the time since the last Ack message was received by this subscription. If there has never been an ack this value should be set to the creation time of the subscription.
      Specified by:
      getTimeOfLastMessageAck in interface Subscription
      Returns:
      time of last received Ack message or Subscription create time if no Acks.
    • setTimeOfLastMessageAck

      public void setTimeOfLastMessageAck(long value)
    • getConsumedCount

      public long getConsumedCount()
      Specified by:
      getConsumedCount in interface Subscription
    • incrementConsumedCount

      public void incrementConsumedCount()
      Specified by:
      incrementConsumedCount in interface Subscription
    • resetConsumedCount

      public void resetConsumedCount()
      Specified by:
      resetConsumedCount in interface Subscription
    • getSubscriptionStatistics

      public SubscriptionStatistics getSubscriptionStatistics()
      Specified by:
      getSubscriptionStatistics in interface Subscription
    • wakeupDestinationsForDispatch

      public void wakeupDestinationsForDispatch()
    • getPrefetchExtension

      public AtomicInteger getPrefetchExtension()
    • contractPrefetchExtension

      protected void contractPrefetchExtension(int amount)
    • expandPrefetchExtension

      protected void expandPrefetchExtension(int amount)
    • decrementPrefetchExtension

      protected void decrementPrefetchExtension(int amount)
    • getDestinations

      public CopyOnWriteArrayList<Destination> getDestinations()