Class Queue

All Implemented Interfaces:
Destination, org.apache.activemq.command.Message.MessageDestination, org.apache.activemq.Service, IndexListener, org.apache.activemq.thread.Task, org.apache.activemq.usage.UsageListener
Direct Known Subclasses:
TempQueue

public class Queue extends BaseDestination implements org.apache.activemq.thread.Task, org.apache.activemq.usage.UsageListener, IndexListener
The Queue is a List of MessageEntry objects that are dispatched to matching subscriptions.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
    • taskFactory

      protected final org.apache.activemq.thread.TaskRunnerFactory taskFactory
    • taskRunner

      protected org.apache.activemq.thread.TaskRunner taskRunner
    • consumers

      protected final List<Subscription> consumers
    • messages

      protected PendingMessageCursor messages
    • dispatchPendingList

      protected QueueDispatchPendingList dispatchPendingList
  • Constructor Details

  • Method Details

    • singlePendingSend

      public boolean singlePendingSend()
    • getConsumers

      public List<Subscription> getConsumers()
      Specified by:
      getConsumers in interface Destination
      Specified by:
      getConsumers in class BaseDestination
    • setPrioritizedMessages

      public void setPrioritizedMessages(boolean prioritizedMessages)
      Overrides:
      setPrioritizedMessages in class BaseDestination
    • initialize

      public void initialize() throws Exception
      Description copied from class: BaseDestination
      initialize the destination
      Overrides:
      initialize in class BaseDestination
      Throws:
      Exception
    • addSubscription

      public void addSubscription(ConnectionContext context, Subscription sub) throws Exception
      Specified by:
      addSubscription in interface Destination
      Overrides:
      addSubscription in class BaseDestination
      Throws:
      Exception
    • removeSubscription

      public void removeSubscription(ConnectionContext context, Subscription sub, long lastDeliveredSequenceId) throws Exception
      Specified by:
      removeSubscription in interface Destination
      Overrides:
      removeSubscription in class BaseDestination
      Throws:
      Exception
    • send

      public void send(ProducerBrokerExchange producerExchange, org.apache.activemq.command.Message message) throws Exception
      Specified by:
      send in interface Destination
      Throws:
      Exception
    • onAdd

      public void onAdd(IndexListener.MessageContext messageContext)
      Description copied from interface: IndexListener
      called with some global index lock held so that a listener can do order dependent work non null MessageContext.onCompletion called when work is done
      Specified by:
      onAdd in interface IndexListener
    • rollbackPendingCursorAdditions

      public void rollbackPendingCursorAdditions(org.apache.activemq.command.MessageId messageId)
    • gc

      public void gc()
      Specified by:
      gc in interface Destination
    • acknowledge

      public void acknowledge(ConnectionContext context, Subscription sub, org.apache.activemq.command.MessageAck ack, org.apache.activemq.broker.region.MessageReference node) throws IOException
      Specified by:
      acknowledge in interface Destination
      Throws:
      IOException
    • getPendingMessageSize

      public long getPendingMessageSize()
    • getPendingMessageCount

      public long getPendingMessageCount()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • start

      public void start() throws Exception
      Specified by:
      start in interface org.apache.activemq.Service
      Throws:
      Exception
    • stop

      public void stop() throws Exception
      Specified by:
      stop in interface org.apache.activemq.Service
      Throws:
      Exception
    • getActiveMQDestination

      public org.apache.activemq.command.ActiveMQDestination getActiveMQDestination()
      Specified by:
      getActiveMQDestination in interface Destination
      Overrides:
      getActiveMQDestination in class BaseDestination
    • getMessageGroupOwners

      public MessageGroupMap getMessageGroupOwners()
    • getDispatchPolicy

      public DispatchPolicy getDispatchPolicy()
    • setDispatchPolicy

      public void setDispatchPolicy(DispatchPolicy dispatchPolicy)
    • getMessageGroupMapFactory

      public MessageGroupMapFactory getMessageGroupMapFactory()
    • setMessageGroupMapFactory

      public void setMessageGroupMapFactory(MessageGroupMapFactory messageGroupMapFactory)
    • getMessages

      public PendingMessageCursor getMessages()
    • setMessages

      public void setMessages(PendingMessageCursor messages)
    • isUseConsumerPriority

      public boolean isUseConsumerPriority()
    • setUseConsumerPriority

      public void setUseConsumerPriority(boolean useConsumerPriority)
    • isStrictOrderDispatch

      public boolean isStrictOrderDispatch()
    • setStrictOrderDispatch

      public void setStrictOrderDispatch(boolean strictOrderDispatch)
    • isOptimizedDispatch

      public boolean isOptimizedDispatch()
    • setOptimizedDispatch

      public void setOptimizedDispatch(boolean optimizedDispatch)
    • getTimeBeforeDispatchStarts

      public int getTimeBeforeDispatchStarts()
    • setTimeBeforeDispatchStarts

      public void setTimeBeforeDispatchStarts(int timeBeforeDispatchStarts)
    • getConsumersBeforeDispatchStarts

      public int getConsumersBeforeDispatchStarts()
    • setConsumersBeforeDispatchStarts

      public void setConsumersBeforeDispatchStarts(int consumersBeforeDispatchStarts)
    • setAllConsumersExclusiveByDefault

      public void setAllConsumersExclusiveByDefault(boolean allConsumersExclusiveByDefault)
    • isAllConsumersExclusiveByDefault

      public boolean isAllConsumersExclusiveByDefault()
    • isResetNeeded

      public boolean isResetNeeded()
    • browse

      public org.apache.activemq.command.Message[] browse()
      Specified by:
      browse in interface Destination
    • doBrowse

      public void doBrowse(List<org.apache.activemq.command.Message> browseList, int max)
    • doBrowseList

      protected void doBrowseList(List<org.apache.activemq.command.Message> browseList, int max, PendingList list, ReentrantReadWriteLock lock, ConnectionContext connectionContext, String name) throws Exception
      Throws:
      Exception
    • getMessage

      public QueueMessageReference getMessage(String id)
    • purge

      public void purge() throws Exception
      Throws:
      Exception
    • clearPendingMessages

      public void clearPendingMessages(int pendingAdditionsCount)
      Specified by:
      clearPendingMessages in interface Destination
    • removeMessage

      public boolean removeMessage(String messageId) throws Exception
      Removes the message matching the given messageId
      Throws:
      Exception
    • removeMatchingMessages

      public int removeMatchingMessages(String selector) throws Exception
      Removes the messages matching the given selector
      Returns:
      the number of messages removed
      Throws:
      Exception
    • removeMatchingMessages

      public int removeMatchingMessages(String selector, int maximumMessages) throws Exception
      Removes the messages matching the given selector up to the maximum number of matched messages
      Returns:
      the number of messages removed
      Throws:
      Exception
    • removeMatchingMessages

      public int removeMatchingMessages(MessageReferenceFilter filter, int maximumMessages) throws Exception
      Removes the messages matching the given filter up to the maximum number of matched messages
      Returns:
      the number of messages removed
      Throws:
      Exception
    • copyMessageTo

      public boolean copyMessageTo(ConnectionContext context, String messageId, org.apache.activemq.command.ActiveMQDestination dest) throws Exception
      Copies the message matching the given messageId
      Throws:
      Exception
    • copyMatchingMessagesTo

      public int copyMatchingMessagesTo(ConnectionContext context, String selector, org.apache.activemq.command.ActiveMQDestination dest) throws Exception
      Copies the messages matching the given selector
      Returns:
      the number of messages copied
      Throws:
      Exception
    • copyMatchingMessagesTo

      public int copyMatchingMessagesTo(ConnectionContext context, String selector, org.apache.activemq.command.ActiveMQDestination dest, int maximumMessages) throws Exception
      Copies the messages matching the given selector up to the maximum number of matched messages
      Returns:
      the number of messages copied
      Throws:
      Exception
    • copyMatchingMessages

      public int copyMatchingMessages(ConnectionContext context, MessageReferenceFilter filter, org.apache.activemq.command.ActiveMQDestination dest, int maximumMessages) throws Exception
      Copies the messages matching the given filter up to the maximum number of matched messages
      Returns:
      the number of messages copied
      Throws:
      Exception
    • moveMessageTo

      public boolean moveMessageTo(ConnectionContext context, QueueMessageReference m, org.apache.activemq.command.ActiveMQDestination dest) throws Exception
      Move a message
      Parameters:
      context - connection context
      m - QueueMessageReference
      dest - ActiveMQDestination
      Throws:
      Exception
    • moveMessageTo

      public boolean moveMessageTo(ConnectionContext context, String messageId, org.apache.activemq.command.ActiveMQDestination dest) throws Exception
      Moves the message matching the given messageId
      Throws:
      Exception
    • moveMatchingMessagesTo

      public int moveMatchingMessagesTo(ConnectionContext context, String selector, org.apache.activemq.command.ActiveMQDestination dest) throws Exception
      Moves the messages matching the given selector
      Returns:
      the number of messages removed
      Throws:
      Exception
    • moveMatchingMessagesTo

      public int moveMatchingMessagesTo(ConnectionContext context, String selector, org.apache.activemq.command.ActiveMQDestination dest, int maximumMessages) throws Exception
      Moves the messages matching the given selector up to the maximum number of matched messages
      Throws:
      Exception
    • moveMatchingMessagesTo

      public int moveMatchingMessagesTo(ConnectionContext context, MessageReferenceFilter filter, org.apache.activemq.command.ActiveMQDestination dest, int maximumMessages) throws Exception
      Moves the messages matching the given filter up to the maximum number of matched messages
      Throws:
      Exception
    • retryMessages

      public int retryMessages(ConnectionContext context, int maximumMessages) throws Exception
      Throws:
      Exception
    • iterate

      public boolean iterate()
      Specified by:
      iterate in interface org.apache.activemq.thread.Task
      Returns:
      true if we would like to iterate again
      See Also:
      • Task.iterate()
    • pauseDispatch

      public void pauseDispatch()
    • resumeDispatch

      public void resumeDispatch()
    • isDispatchPaused

      public boolean isDispatchPaused()
    • createMessageIdFilter

      protected MessageReferenceFilter createMessageIdFilter(String messageId)
    • createSelectorFilter

      protected MessageReferenceFilter createSelectorFilter(String selector) throws jakarta.jms.InvalidSelectorException
      Throws:
      jakarta.jms.InvalidSelectorException
    • removeMessage

      protected void removeMessage(ConnectionContext c, QueueMessageReference r) throws IOException
      Throws:
      IOException
    • removeMessage

      protected void removeMessage(ConnectionContext c, Subscription subs, QueueMessageReference r) throws IOException
      Throws:
      IOException
    • removeMessage

      protected void removeMessage(ConnectionContext context, Subscription sub, QueueMessageReference reference, org.apache.activemq.command.MessageAck ack) throws IOException
      Throws:
      IOException
    • messageExpired

      public void messageExpired(ConnectionContext context, org.apache.activemq.broker.region.MessageReference reference)
    • messageExpired

      public void messageExpired(ConnectionContext context, Subscription subs, org.apache.activemq.broker.region.MessageReference reference)
      Description copied from interface: Destination
      Inform the Destination a message has expired
      Specified by:
      messageExpired in interface Destination
    • wakeup

      public void wakeup()
      Description copied from interface: Destination
      optionally called by a Subscriber - to inform the Destination its ready for more messages
      Specified by:
      wakeup in interface Destination
    • assignMessageGroup

      protected boolean assignMessageGroup(Subscription subscription, QueueMessageReference node) throws Exception
      Throws:
      Exception
    • assignGroup

      protected void assignGroup(Subscription subs, MessageGroupMap messageGroupOwners, org.apache.activemq.broker.region.MessageReference n, String groupId) throws IOException
      Throws:
      IOException
    • pageInMessages

      protected void pageInMessages(boolean force, int maxPageSize) throws Exception
      Throws:
      Exception
    • processDispatchNotification

      public void processDispatchNotification(org.apache.activemq.command.MessageDispatchNotification messageDispatchNotification) throws Exception
      Description copied from interface: Destination
      called on Queues in slave mode to allow dispatch to follow subscription choice of master
      Specified by:
      processDispatchNotification in interface Destination
      Overrides:
      processDispatchNotification in class BaseDestination
      Throws:
      Exception
    • onUsageChanged

      public void onUsageChanged(org.apache.activemq.usage.Usage usage, int oldPercentUsage, int newPercentUsage)
      Specified by:
      onUsageChanged in interface org.apache.activemq.usage.UsageListener
    • getLog

      protected org.slf4j.Logger getLog()
      Specified by:
      getLog in class BaseDestination
    • isOptimizeStorage

      protected boolean isOptimizeStorage()