Class BaseDestination

java.lang.Object
org.apache.activemq.broker.region.BaseDestination
All Implemented Interfaces:
Destination, org.apache.activemq.command.Message.MessageDestination, org.apache.activemq.Service, org.apache.activemq.thread.Task
Direct Known Subclasses:
Queue, Topic

public abstract class BaseDestination extends Object implements Destination
  • Field Details

    • MAX_PAGE_SIZE

      public static final int MAX_PAGE_SIZE
      The maximum number of messages to page in to the destination from persistent storage
      See Also:
    • MAX_BROWSE_PAGE_SIZE

      public static final int MAX_BROWSE_PAGE_SIZE
      See Also:
    • EXPIRE_MESSAGE_PERIOD

      public static final long EXPIRE_MESSAGE_PERIOD
      See Also:
    • DEFAULT_INACTIVE_TIMEOUT_BEFORE_GC

      public static final long DEFAULT_INACTIVE_TIMEOUT_BEFORE_GC
      See Also:
    • MAX_PRODUCERS_TO_AUDIT

      public static final int MAX_PRODUCERS_TO_AUDIT
      See Also:
    • MAX_AUDIT_DEPTH

      public static final int MAX_AUDIT_DEPTH
      See Also:
    • DUPLICATE_FROM_STORE_MSG_PREFIX

      public static final String DUPLICATE_FROM_STORE_MSG_PREFIX
      See Also:
    • started

      protected final AtomicBoolean started
    • destination

      protected final org.apache.activemq.command.ActiveMQDestination destination
    • broker

      protected final Broker broker
    • store

      protected final MessageStore store
    • systemUsage

      protected SystemUsage systemUsage
    • memoryUsage

      protected org.apache.activemq.usage.MemoryUsage memoryUsage
    • lastBlockedProducerWarnTime

      protected long lastBlockedProducerWarnTime
    • blockedProducerWarningInterval

      protected long blockedProducerWarningInterval
    • destinationStatistics

      protected final DestinationStatistics destinationStatistics
    • brokerService

      protected final BrokerService brokerService
    • regionBroker

      protected final Broker regionBroker
    • deadLetterStrategy

      protected DeadLetterStrategy deadLetterStrategy
    • expireMessagesPeriod

      protected long expireMessagesPeriod
    • cursorMemoryHighWaterMark

      protected int cursorMemoryHighWaterMark
    • storeUsageHighWaterMark

      protected int storeUsageHighWaterMark
    • scheduler

      protected final org.apache.activemq.thread.Scheduler scheduler
  • Constructor Details

  • Method Details

    • initialize

      public void initialize() throws Exception
      initialize the destination
      Throws:
      Exception
    • isProducerFlowControl

      public boolean isProducerFlowControl()
      Specified by:
      isProducerFlowControl in interface Destination
      Returns:
      the producerFlowControl
    • setProducerFlowControl

      public void setProducerFlowControl(boolean producerFlowControl)
      Specified by:
      setProducerFlowControl in interface Destination
      Parameters:
      producerFlowControl - the producerFlowControl to set
    • isAlwaysRetroactive

      public boolean isAlwaysRetroactive()
      Specified by:
      isAlwaysRetroactive in interface Destination
    • setAlwaysRetroactive

      public void setAlwaysRetroactive(boolean alwaysRetroactive)
      Specified by:
      setAlwaysRetroactive in interface Destination
    • setBlockedProducerWarningInterval

      public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval)
      Set's the interval at which warnings about producers being blocked by resource usage will be triggered. Values of 0 or less will disable warnings
      Specified by:
      setBlockedProducerWarningInterval in interface Destination
      Parameters:
      blockedProducerWarningInterval - the interval at which warning about blocked producers will be triggered.
    • getBlockedProducerWarningInterval

      public long getBlockedProducerWarningInterval()
      Specified by:
      getBlockedProducerWarningInterval in interface Destination
      Returns:
      the interval at which warning about blocked producers will be triggered.
    • getMaxProducersToAudit

      public int getMaxProducersToAudit()
      Specified by:
      getMaxProducersToAudit in interface Destination
      Returns:
      the maxProducersToAudit
    • setMaxProducersToAudit

      public void setMaxProducersToAudit(int maxProducersToAudit)
      Specified by:
      setMaxProducersToAudit in interface Destination
      Parameters:
      maxProducersToAudit - the maxProducersToAudit to set
    • getMaxAuditDepth

      public int getMaxAuditDepth()
      Specified by:
      getMaxAuditDepth in interface Destination
      Returns:
      the maxAuditDepth
    • setMaxAuditDepth

      public void setMaxAuditDepth(int maxAuditDepth)
      Specified by:
      setMaxAuditDepth in interface Destination
      Parameters:
      maxAuditDepth - the maxAuditDepth to set
    • isEnableAudit

      public boolean isEnableAudit()
      Specified by:
      isEnableAudit in interface Destination
      Returns:
      the enableAudit
    • setEnableAudit

      public void setEnableAudit(boolean enableAudit)
      Specified by:
      setEnableAudit in interface Destination
      Parameters:
      enableAudit - the enableAudit to set
    • addProducer

      public void addProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info) throws Exception
      Specified by:
      addProducer in interface Destination
      Throws:
      Exception
    • removeProducer

      public void removeProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo info) throws Exception
      Specified by:
      removeProducer in interface Destination
      Throws:
      Exception
    • addSubscription

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

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

      public final org.apache.activemq.usage.MemoryUsage getMemoryUsage()
      Specified by:
      getMemoryUsage in interface Destination
      Specified by:
      getMemoryUsage in interface org.apache.activemq.command.Message.MessageDestination
    • setMemoryUsage

      public void setMemoryUsage(org.apache.activemq.usage.MemoryUsage memoryUsage)
      Specified by:
      setMemoryUsage in interface Destination
    • getTempUsage

      public TempUsage getTempUsage()
      Specified by:
      getTempUsage in interface Destination
    • getDestinationStatistics

      public DestinationStatistics getDestinationStatistics()
      Specified by:
      getDestinationStatistics in interface Destination
    • getActiveMQDestination

      public org.apache.activemq.command.ActiveMQDestination getActiveMQDestination()
      Specified by:
      getActiveMQDestination in interface Destination
    • getName

      public final String getName()
      Specified by:
      getName in interface Destination
    • getMessageStore

      public final MessageStore getMessageStore()
      Specified by:
      getMessageStore in interface Destination
    • isActive

      public boolean isActive()
      Specified by:
      isActive in interface Destination
    • getMaxPageSize

      public int getMaxPageSize()
      Specified by:
      getMaxPageSize in interface Destination
    • setMaxPageSize

      public void setMaxPageSize(int maxPageSize)
      Specified by:
      setMaxPageSize in interface Destination
    • getMaxBrowsePageSize

      public int getMaxBrowsePageSize()
      Specified by:
      getMaxBrowsePageSize in interface Destination
    • setMaxBrowsePageSize

      public void setMaxBrowsePageSize(int maxPageSize)
      Specified by:
      setMaxBrowsePageSize in interface Destination
    • getMaxExpirePageSize

      public int getMaxExpirePageSize()
    • setMaxExpirePageSize

      public void setMaxExpirePageSize(int maxPageSize)
    • setExpireMessagesPeriod

      public void setExpireMessagesPeriod(long expireMessagesPeriod)
    • getExpireMessagesPeriod

      public long getExpireMessagesPeriod()
    • isUseCache

      public boolean isUseCache()
      Specified by:
      isUseCache in interface Destination
    • setUseCache

      public void setUseCache(boolean useCache)
      Specified by:
      setUseCache in interface Destination
    • getMinimumMessageSize

      public int getMinimumMessageSize()
      Specified by:
      getMinimumMessageSize in interface Destination
      Specified by:
      getMinimumMessageSize in interface org.apache.activemq.command.Message.MessageDestination
    • setMinimumMessageSize

      public void setMinimumMessageSize(int minimumMessageSize)
      Specified by:
      setMinimumMessageSize in interface Destination
    • isLazyDispatch

      public boolean isLazyDispatch()
      Specified by:
      isLazyDispatch in interface Destination
      Returns:
      true if lazyDispatch is enabled
    • setLazyDispatch

      public void setLazyDispatch(boolean lazyDispatch)
      Description copied from interface: Destination
      set the lazy dispatch - default is false
      Specified by:
      setLazyDispatch in interface Destination
    • getDestinationSequenceId

      protected long getDestinationSequenceId()
    • isAdvisoryForSlowConsumers

      public boolean isAdvisoryForSlowConsumers()
      Returns:
      the advisoryForSlowConsumers
    • setAdvisoryForSlowConsumers

      public void setAdvisoryForSlowConsumers(boolean advisoryForSlowConsumers)
      Parameters:
      advisoryForSlowConsumers - the advisoryForSlowConsumers to set
    • isAdvisoryForDiscardingMessages

      public boolean isAdvisoryForDiscardingMessages()
      Returns:
      the advisoryForDiscardingMessages
    • setAdvisoryForDiscardingMessages

      public void setAdvisoryForDiscardingMessages(boolean advisoryForDiscardingMessages)
      Parameters:
      advisoryForDiscardingMessages - the advisoryForDiscardingMessages to set
    • isAdvisoryWhenFull

      public boolean isAdvisoryWhenFull()
      Returns:
      the advisoryWhenFull
    • setAdvisoryWhenFull

      public void setAdvisoryWhenFull(boolean advisoryWhenFull)
      Parameters:
      advisoryWhenFull - the advisoryWhenFull to set
    • isAdvisoryForDelivery

      public boolean isAdvisoryForDelivery()
      Returns:
      the advisoryForDelivery
    • setAdvisoryForDelivery

      public void setAdvisoryForDelivery(boolean advisoryForDelivery)
      Parameters:
      advisoryForDelivery - the advisoryForDelivery to set
    • isAdvisoryForConsumed

      public boolean isAdvisoryForConsumed()
      Returns:
      the advisoryForConsumed
    • setAdvisoryForConsumed

      public void setAdvisoryForConsumed(boolean advisoryForConsumed)
      Parameters:
      advisoryForConsumed - the advisoryForConsumed to set
    • isAdvisoryForDispatched

      public boolean isAdvisoryForDispatched()
    • setAdvisoryForDispatched

      public void setAdvisoryForDispatched(boolean advisoryForDispatched)
    • isAdvisoryForFastProducers

      public boolean isAdvisoryForFastProducers()
      Returns:
      the advisdoryForFastProducers
    • setAdvisoryForFastProducers

      public void setAdvisoryForFastProducers(boolean advisoryForFastProducers)
      Parameters:
      advisoryForFastProducers - the advisdoryForFastProducers to set
    • isSendAdvisoryIfNoConsumers

      public boolean isSendAdvisoryIfNoConsumers()
    • setSendAdvisoryIfNoConsumers

      public void setSendAdvisoryIfNoConsumers(boolean sendAdvisoryIfNoConsumers)
    • isSendDuplicateFromStoreToDLQ

      public boolean isSendDuplicateFromStoreToDLQ()
      Specified by:
      isSendDuplicateFromStoreToDLQ in interface Destination
    • setSendDuplicateFromStoreToDLQ

      public void setSendDuplicateFromStoreToDLQ(boolean sendDuplicateFromStoreToDLQ)
      Specified by:
      setSendDuplicateFromStoreToDLQ in interface Destination
    • isIncludeBodyForAdvisory

      public boolean isIncludeBodyForAdvisory()
    • setIncludeBodyForAdvisory

      public void setIncludeBodyForAdvisory(boolean includeBodyForAdvisory)
    • getDeadLetterStrategy

      public DeadLetterStrategy getDeadLetterStrategy()
      Specified by:
      getDeadLetterStrategy in interface Destination
      Returns:
      the dead letter strategy
    • setDeadLetterStrategy

      public void setDeadLetterStrategy(DeadLetterStrategy deadLetterStrategy)
      set the dead letter strategy
      Parameters:
      deadLetterStrategy -
    • getCursorMemoryHighWaterMark

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

      public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark)
      Specified by:
      setCursorMemoryHighWaterMark in interface Destination
    • messageConsumed

      public void messageConsumed(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference)
      called when message is consumed
      Specified by:
      messageConsumed in interface Destination
      Parameters:
      context -
      messageReference -
    • messageDelivered

      public void messageDelivered(ConnectionContext context, org.apache.activemq.broker.region.MessageReference messageReference)
      Called when message is delivered to the broker
      Specified by:
      messageDelivered in interface Destination
      Parameters:
      context -
      messageReference -
    • messageDispatched

      public void messageDispatched(ConnectionContext context, Subscription sub, org.apache.activemq.broker.region.MessageReference messageReference)
      Description copied from interface: Destination
      Called when message is dispatched to a consumer
      Specified by:
      messageDispatched in interface Destination
    • messageDiscarded

      public void messageDiscarded(ConnectionContext context, Subscription sub, org.apache.activemq.broker.region.MessageReference messageReference)
      Called when a message is discarded - e.g. running low on memory This will happen only if the policy is enabled - e.g. non durable topics
      Specified by:
      messageDiscarded in interface Destination
      Parameters:
      context -
      messageReference -
    • slowConsumer

      public void slowConsumer(ConnectionContext context, Subscription subs)
      Called when there is a slow consumer
      Specified by:
      slowConsumer in interface Destination
      Parameters:
      context -
      subs -
    • fastProducer

      public void fastProducer(ConnectionContext context, org.apache.activemq.command.ProducerInfo producerInfo)
      Called to notify a producer is too fast
      Specified by:
      fastProducer in interface Destination
      Parameters:
      context -
      producerInfo -
    • isFull

      public void isFull(ConnectionContext context, org.apache.activemq.usage.Usage<?> usage)
      Called when a Usage reaches a limit
      Specified by:
      isFull in interface Destination
      Parameters:
      context -
      usage -
    • dispose

      public void dispose(ConnectionContext context) throws IOException
      Specified by:
      dispose in interface Destination
      Throws:
      IOException
    • isDisposed

      public boolean isDisposed()
      Specified by:
      isDisposed in interface Destination
    • onMessageWithNoConsumers

      protected void onMessageWithNoConsumers(ConnectionContext context, org.apache.activemq.command.Message msg) throws Exception
      Provides a hook to allow messages with no consumer to be processed in some way - such as to send to a dead letter queue or something..
      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
      Throws:
      Exception
    • getStoreUsageHighWaterMark

      public final int getStoreUsageHighWaterMark()
    • setStoreUsageHighWaterMark

      public void setStoreUsageHighWaterMark(int storeUsageHighWaterMark)
    • waitForSpace

      protected final void waitForSpace(ConnectionContext context, ProducerBrokerExchange producerBrokerExchange, org.apache.activemq.usage.Usage<?> usage, String warning) throws IOException, InterruptedException, jakarta.jms.ResourceAllocationException
      Throws:
      IOException
      InterruptedException
      jakarta.jms.ResourceAllocationException
    • waitForSpace

      protected final void waitForSpace(ConnectionContext context, ProducerBrokerExchange producerBrokerExchange, org.apache.activemq.usage.Usage<?> usage, int highWaterMark, String warning) throws IOException, InterruptedException, jakarta.jms.ResourceAllocationException
      Throws:
      IOException
      InterruptedException
      jakarta.jms.ResourceAllocationException
    • isFlowControlLogRequired

      protected boolean isFlowControlLogRequired()
    • getLog

      protected abstract org.slf4j.Logger getLog()
    • setSlowConsumerStrategy

      public void setSlowConsumerStrategy(SlowConsumerStrategy slowConsumerStrategy)
    • getSlowConsumerStrategy

      public SlowConsumerStrategy getSlowConsumerStrategy()
      Specified by:
      getSlowConsumerStrategy in interface Destination
    • isPrioritizedMessages

      public boolean isPrioritizedMessages()
      Specified by:
      isPrioritizedMessages in interface Destination
    • setPrioritizedMessages

      public void setPrioritizedMessages(boolean prioritizedMessages)
    • getInactiveTimeoutBeforeGC

      public long getInactiveTimeoutBeforeGC()
      Specified by:
      getInactiveTimeoutBeforeGC in interface Destination
      Returns:
      the inactiveTimeoutBeforeGC
    • setInactiveTimeoutBeforeGC

      public void setInactiveTimeoutBeforeGC(long inactiveTimeoutBeforeGC)
      Parameters:
      inactiveTimeoutBeforeGC - the inactiveTimeoutBeforeGC to set
    • isGcIfInactive

      public boolean isGcIfInactive()
      Returns:
      the gcIfInactive
    • setGcIfInactive

      public void setGcIfInactive(boolean gcIfInactive)
      Parameters:
      gcIfInactive - the gcIfInactive to set
    • setGcWithNetworkConsumers

      public void setGcWithNetworkConsumers(boolean gcWithNetworkConsumers)
      Indicate if it is ok to gc destinations that have only network consumers
      Parameters:
      gcWithNetworkConsumers -
    • isGcWithNetworkConsumers

      public boolean isGcWithNetworkConsumers()
    • markForGC

      public void markForGC(long timeStamp)
      Specified by:
      markForGC in interface Destination
    • canGC

      public boolean canGC()
      Specified by:
      canGC in interface Destination
    • setReduceMemoryFootprint

      public void setReduceMemoryFootprint(boolean reduceMemoryFootprint)
    • isReduceMemoryFootprint

      public boolean isReduceMemoryFootprint()
    • isDoOptimzeMessageStorage

      public boolean isDoOptimzeMessageStorage()
      Specified by:
      isDoOptimzeMessageStorage in interface Destination
    • setDoOptimzeMessageStorage

      public void setDoOptimzeMessageStorage(boolean doOptimzeMessageStorage)
      Specified by:
      setDoOptimzeMessageStorage in interface Destination
    • getOptimizeMessageStoreInFlightLimit

      public int getOptimizeMessageStoreInFlightLimit()
    • setOptimizeMessageStoreInFlightLimit

      public void setOptimizeMessageStoreInFlightLimit(int optimizeMessageStoreInFlightLimit)
    • isAdvancedNetworkStatisticsEnabled

      public boolean isAdvancedNetworkStatisticsEnabled()
      Specified by:
      isAdvancedNetworkStatisticsEnabled in interface Destination
    • setAdvancedNetworkStatisticsEnabled

      public void setAdvancedNetworkStatisticsEnabled(boolean advancedNetworkStatisticsEnabled)
      Specified by:
      setAdvancedNetworkStatisticsEnabled in interface Destination
    • isAdvancedMessageStatisticsEnabled

      public boolean isAdvancedMessageStatisticsEnabled()
      Specified by:
      isAdvancedMessageStatisticsEnabled in interface Destination
    • setAdvancedMessageStatisticsEnabled

      public void setAdvancedMessageStatisticsEnabled(boolean advancedMessageStatisticsEnabled)
      Specified by:
      setAdvancedMessageStatisticsEnabled in interface Destination
    • getConsumers

      public abstract List<Subscription> getConsumers()
      Specified by:
      getConsumers in interface Destination
    • hasRegularConsumers

      protected boolean hasRegularConsumers(List<Subscription> consumers)
    • createConnectionContext

      public ConnectionContext createConnectionContext()
    • convertToNonRangedAck

      protected org.apache.activemq.command.MessageAck convertToNonRangedAck(org.apache.activemq.command.MessageAck ack, org.apache.activemq.broker.region.MessageReference node)
    • isDLQ

      protected boolean isDLQ()
    • duplicateFromStore

      public void duplicateFromStore(org.apache.activemq.command.Message message, Subscription subscription)
      Specified by:
      duplicateFromStore in interface Destination
    • setPersistJMSRedelivered

      public void setPersistJMSRedelivered(boolean persistJMSRedelivered)
    • isPersistJMSRedelivered

      public boolean isPersistJMSRedelivered()
    • getSystemUsage

      public SystemUsage getSystemUsage()
    • getMessageInterceptorStrategy

      public MessageInterceptorStrategy getMessageInterceptorStrategy()
    • setMessageInterceptorStrategy

      public void setMessageInterceptorStrategy(MessageInterceptorStrategy messageInterceptorStrategy)