layout: default_md title: Per Destination Policies title-class: page-title-activemq5 type: activemq5

Features > Destination Features > Per Destination Policies

Multiple different policies can be applied per destination (queue or topic), or using wildcard notation to apply to a hierarchy of queues or topics, making it possible, therefore, to configure how different regions of the JMS destination space are handled.

The following properties can be applied to either topics and/or queues:

Common PropertyDefaultDescription
advisoryForConsumedfalseSend an advisory message when a message is consumed by a client.
advisoryForDeliveryfalseSend an advisory message when a message is sent to a client.
advisoryForFastProducersfalseSend an advisory message if a producer is deemed fast.
advisoryForSlowConsumersfalseSend an advisory message if a consumer is deemed slow.
advisoryWhenFullfalseSend an advisory message when a limit (memory, store, temp disk) is full.
enableAudittrueWhen true the broker will track duplicate messages. Duplicates can happen for non-persistent messages during failover.
gcInactiveDestinationsfalseGarbage collect inactive destinations.
inactiveTimoutBeforeGC5000The timeout (in ms) after which a destination is considered inactive.
includeBodyForAdvisoryfalseIncludes the body of the original message that triggered the advisory as part of the dataStructure field in the advisory message (where applicable). Normally the message body is cleared.
maxBrowsePageSize400The maximum number of messages to page in from the store at one time for a browser.
maxDestinations-1(v5.12) If >= 0, sets the maximum number of destinations that can be created. This parameter is intended to limit the number of hierarchical destinations that can be created under a wildcard destination.
maxPageSize200The maximum number of messages to page in from the store at one time. Increase this value to improve performance for queue destination's that contain grouped messages that are consumed by multiple concurrent consumers.
memoryLimitn/aThe memory limit (in bytes) of the destination‘s cursor. This memory limit is subordinate to the system level memory limit, as specified by the <systemUsage>/<memoryUsage> attribute. There is no default for this value; it simply acts as a child to the overall broker memory until the broker memory is exhausted. Note: when this limit is specified the destination’s cursorMemoryHighWaterMark will be applied against it and not the <systemUsage>/><memoryUsage> memory limit.
minimumMessageSize1024For non-serialized messages (embedded broker) - the assumed size of the message used for memory usage calculation. Serialized messages use the serialized size as the basis for the memory calculation.
prioritizedMessagesfalsePersist message priority information.
producerFlowControltrueIf true the broker will throttle (flow-control) the producer. Throttling is achieved either by withholding the producer‘s ACK or by raising a javax.jms.ResourceAllocationException (that’s propagated back to the client) when local resources, e.g., memory and/or storage, have been exhausted. If false excess messages will be written to the message store to prevent memory exhaustion. However, when the message store reaches capacity the producer will be throttled until resources are freed.
slowConsumerStrategynullSets the strategy for handling slow consumers. See AbortSlowConsumerStrategy.
storeUsageHighWaterMark100The percentage (%) threshold of the <systemUsage>/<storeUsage> store limit which when exceeded causes a producer send to block.
useCachetrueIf true persistent messages are cached for fast retrieval from store.
usePrefetchExtensiontrueThe prefetch extension is used when a message is delivered but not ACK'ed, such that the broker can dispatch another message, e.g., prefetch == 0, the idea being that there will always be prefetch number of messages pending. It also allows a transaction batch to exceed the prefetch value.
sendFailIfNoSpacefalse(v5.16.0) If true, will cause a send to fail with a javax.jms.ResourceAllocationException when the destination has reached is resource limits (memory or storage)
sendFailIfNoSpaceAfterTimeout0(v5.16.0) If > 0, will cause a send to fail with a javax.jms.ResourceAllocationException when the destination resource limits (memory or storage) remain exhausted for the configured duration in milliseconds

The following properties can be applied only to a queue:

Queue Only PropertyDefaultDescription
allConsumersExclusiveByDefaultfalseWhen true all consumers will be exclusive. See ActiveMQ Exclusive Consumers
cursorMemoryHighWaterMark70The percentage (%) threshold applied either to the <systemUsage>/<memoryUsage> or the destination‘s memoryLimit (when defined) which when exceeded will cause the destination’s cursor to either block or write to disk.
consumersBeforeDispatchStarts0When the first consumer connects, wait for specified number of consumers before message dispatching starts.
expireMessagesPeriod30000The period (in ms) of checks for message expiry on queued messages. A value of 0 will disable expiration checking.
lazyDispatchfalseOnly page in from store the number of messages that can be dispatched at time.
maxExpirePageSize400The maximum number of messages to page in when periodically expiring messages. Messages are paged in according to this setting if the number of messages in memory pending dispatch is less than this value, and there are messages in the store to page in. Messages are expired during this paging step as they are brought into memory from the store. Once the paging process is completed, messages are expired from the list of those that are in memory and pending dispatch, then from the list of those that are in memory but not yet targeted at a subscription.
optimizedDispatchfalseDon't use a separate thread for dispatching from a Queue.
persistJMSRedeliveredfalse(v 5.10) If true, before a persistent message is dispatched by the broker for the first time, the message is rewritten to reflect the possible delivery. This ensures the message JMSRedelivered header is a reliable indication of possible duplicate delivery.
queuePrefetchn/aSets the prefetch for consumers that are using the default value.
strictOrderDispatchfalseIf true queue will not round robin consumers, but it'll use a single one until its prefetch buffer is full.
timeBeforeDispatchStarts0When the first consumer connects, wait for specified time (in ms) before message dispatching starts.
useConsumerPrioritytrueUse the priority of a consumer when dispatching messages from a Queue.

The following properties can be applied only to a topic:

Topic Only PropertyDefaultDescription
advisoryForDiscardingMessagesfalseSend an advisory when a message is discarded from a non durable subscription.
cursorMemoryHighWaterMark70The percentage (%) threshold applied to the <systemUsage>/<memoryUsage> which when exceeded will cause the destination's cursor to either block or write to disk.
alwaysRetroactivefalseMakes all subscribers retroactive negating the need to modify the clients to enable this feature.
durableTopicPrefetchn/aSets the prefetch for durable topic consumers that are using the default value.
expireMessagesPeriod30000The interval (in ms) between message expiration checks on inactive durable subscribers. Note: set to 0 to disable message expiration checking.
topicPrefetchn/aSets the prefetch for topic consumers that are using the default value.

The following are examples of different policies that can be customized on a per destination basis:

An example from the demos https://git-wip-us.apache.org/repos/asf?p=activemq.git;a=blob;f=assembly/src/release/examples/conf/activemq-demo.xml;hb=HEAD

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:amq="http://activemq.apache.org/schema/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
 
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
 
  <broker persistent="false" 
          brokerName="${brokername}" 
          xmlns="http://activemq.apache.org/schema/core">
    
    <destinationPolicy>
      <policyMap>
        <policyEntries>
          <policyEntry topic="FOO.>">
            <dispatchPolicy>
              <roundRobinDispatchPolicy/>
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy/>
            </subscriptionRecoveryPolicy>
          </policyEntry>
           
          <policyEntry topic="ORDERS.>">
            <dispatchPolicy>
              <strictOrderDispatchPolicy/>
            </dispatchPolicy>
 
            <!-- Recover 1 minute's worth -->
            <subscriptionRecoveryPolicy>
              <timedSubscriptionRecoveryPolicy recoverDuration="60000"/>
            </subscriptionRecoveryPolicy>
          </policyEntry>
     
          <policyEntry topic="PRICES.>">
            <!-- Force pending messages to be discarded for slow consumers -->
            <pendingMessageLimitStrategy>
              <constantPendingMessageLimitStrategy limit="10"/>
            </pendingMessageLimitStrategy>
 
            <!-- 10 seconds worth -->
            <subscriptionRecoveryPolicy>
              <timedSubscriptionRecoveryPolicy recoverDuration="10000"/>
            </subscriptionRecoveryPolicy>
             
          </policyEntry>
          <policyEntry tempTopic="true" advisoryForConsumed="true"/>
          <policyEntry tempQueue="true" advisoryForConsumed="true"/>
        </policyEntries>
      </policyMap>
    </destinationPolicy>
  </broker>
</beans>