001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.broker.region.policy;
018
019import org.apache.activemq.ActiveMQPrefetchPolicy;
020import org.apache.activemq.broker.Broker;
021import org.apache.activemq.broker.region.BaseDestination;
022import org.apache.activemq.broker.region.Destination;
023import org.apache.activemq.broker.region.DurableTopicSubscription;
024import org.apache.activemq.broker.region.Queue;
025import org.apache.activemq.broker.region.QueueBrowserSubscription;
026import org.apache.activemq.broker.region.QueueSubscription;
027import org.apache.activemq.broker.region.Subscription;
028import org.apache.activemq.broker.region.Topic;
029import org.apache.activemq.broker.region.TopicSubscription;
030import org.apache.activemq.broker.region.cursors.PendingMessageCursor;
031import org.apache.activemq.broker.region.group.GroupFactoryFinder;
032import org.apache.activemq.broker.region.group.MessageGroupMapFactory;
033import org.apache.activemq.filter.DestinationMapEntry;
034import org.apache.activemq.network.NetworkBridgeFilterFactory;
035import org.apache.activemq.usage.SystemUsage;
036import org.slf4j.Logger;
037import org.slf4j.LoggerFactory;
038
039/**
040 * Represents an entry in a {@link PolicyMap} for assigning policies to a
041 * specific destination or a hierarchical wildcard area of destinations.
042 *
043 * @org.apache.xbean.XBean
044 *
045 */
046public class PolicyEntry extends DestinationMapEntry {
047
048    private static final Logger LOG = LoggerFactory.getLogger(PolicyEntry.class);
049    private DispatchPolicy dispatchPolicy;
050    private SubscriptionRecoveryPolicy subscriptionRecoveryPolicy;
051    private boolean sendAdvisoryIfNoConsumers;
052    private DeadLetterStrategy deadLetterStrategy = Destination.DEFAULT_DEAD_LETTER_STRATEGY;
053    private PendingMessageLimitStrategy pendingMessageLimitStrategy;
054    private MessageEvictionStrategy messageEvictionStrategy;
055    private long memoryLimit;
056    private String messageGroupMapFactoryType = "cached";
057    private MessageGroupMapFactory messageGroupMapFactory;
058    private PendingQueueMessageStoragePolicy pendingQueuePolicy;
059    private PendingDurableSubscriberMessageStoragePolicy pendingDurableSubscriberPolicy;
060    private PendingSubscriberMessageStoragePolicy pendingSubscriberPolicy;
061    private int maxProducersToAudit=BaseDestination.MAX_PRODUCERS_TO_AUDIT;
062    private int maxAuditDepth=BaseDestination.MAX_AUDIT_DEPTH;
063    private int maxQueueAuditDepth=BaseDestination.MAX_AUDIT_DEPTH;
064    private boolean enableAudit=true;
065    private boolean producerFlowControl = true;
066    private boolean alwaysRetroactive = false;
067    private long blockedProducerWarningInterval = Destination.DEFAULT_BLOCKED_PRODUCER_WARNING_INTERVAL;
068    private boolean optimizedDispatch=false;
069    private int maxPageSize=BaseDestination.MAX_PAGE_SIZE;
070    private int maxBrowsePageSize=BaseDestination.MAX_BROWSE_PAGE_SIZE;
071    private boolean useCache=true;
072    private long minimumMessageSize=1024;
073    private boolean useConsumerPriority=true;
074    private boolean strictOrderDispatch=false;
075    private boolean lazyDispatch=false;
076    private int timeBeforeDispatchStarts = 0;
077    private int consumersBeforeDispatchStarts = 0;
078    private boolean advisoryForSlowConsumers;
079    private boolean advisoryForFastProducers;
080    private boolean advisoryForDiscardingMessages;
081    private boolean advisoryWhenFull;
082    private boolean advisoryForDelivery;
083    private boolean advisoryForConsumed;
084    private boolean includeBodyForAdvisory;
085    private long expireMessagesPeriod = BaseDestination.EXPIRE_MESSAGE_PERIOD;
086    private int maxExpirePageSize = BaseDestination.MAX_BROWSE_PAGE_SIZE;
087    private int queuePrefetch=ActiveMQPrefetchPolicy.DEFAULT_QUEUE_PREFETCH;
088    private int queueBrowserPrefetch=ActiveMQPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH;
089    private int topicPrefetch=ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH;
090    private int durableTopicPrefetch=ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH;
091    private boolean usePrefetchExtension = true;
092    private int cursorMemoryHighWaterMark = 70;
093    private int storeUsageHighWaterMark = 100;
094    private SlowConsumerStrategy slowConsumerStrategy;
095    private boolean prioritizedMessages;
096    private boolean allConsumersExclusiveByDefault;
097    private boolean gcInactiveDestinations;
098    private boolean gcWithNetworkConsumers;
099    private long inactiveTimeoutBeforeGC = BaseDestination.DEFAULT_INACTIVE_TIMEOUT_BEFORE_GC;
100    private boolean reduceMemoryFootprint;
101    private NetworkBridgeFilterFactory networkBridgeFilterFactory;
102    private boolean doOptimzeMessageStorage = true;
103    private int maxDestinations = -1;
104
105    /*
106     * percentage of in-flight messages above which optimize message store is disabled
107     */
108    private int optimizeMessageStoreInFlightLimit = 10;
109    private boolean persistJMSRedelivered = false;
110
111
112    public void configure(Broker broker,Queue queue) {
113        baseConfiguration(broker,queue);
114        if (dispatchPolicy != null) {
115            queue.setDispatchPolicy(dispatchPolicy);
116        }
117        queue.setDeadLetterStrategy(getDeadLetterStrategy());
118        queue.setMessageGroupMapFactory(getMessageGroupMapFactory());
119        if (memoryLimit > 0) {
120            queue.getMemoryUsage().setLimit(memoryLimit);
121        }
122        if (pendingQueuePolicy != null) {
123            PendingMessageCursor messages = pendingQueuePolicy.getQueuePendingMessageCursor(broker,queue);
124            queue.setMessages(messages);
125        }
126
127        queue.setUseConsumerPriority(isUseConsumerPriority());
128        queue.setStrictOrderDispatch(isStrictOrderDispatch());
129        queue.setOptimizedDispatch(isOptimizedDispatch());
130        queue.setLazyDispatch(isLazyDispatch());
131        queue.setTimeBeforeDispatchStarts(getTimeBeforeDispatchStarts());
132        queue.setConsumersBeforeDispatchStarts(getConsumersBeforeDispatchStarts());
133        queue.setAllConsumersExclusiveByDefault(isAllConsumersExclusiveByDefault());
134        queue.setPersistJMSRedelivered(isPersistJMSRedelivered());
135    }
136
137    public void update(Queue queue) {
138        baseUpdate(queue);
139        if (memoryLimit > 0) {
140            queue.getMemoryUsage().setLimit(memoryLimit);
141        }
142        queue.setUseConsumerPriority(isUseConsumerPriority());
143        queue.setStrictOrderDispatch(isStrictOrderDispatch());
144        queue.setOptimizedDispatch(isOptimizedDispatch());
145        queue.setLazyDispatch(isLazyDispatch());
146        queue.setTimeBeforeDispatchStarts(getTimeBeforeDispatchStarts());
147        queue.setConsumersBeforeDispatchStarts(getConsumersBeforeDispatchStarts());
148        queue.setAllConsumersExclusiveByDefault(isAllConsumersExclusiveByDefault());
149        queue.setPersistJMSRedelivered(isPersistJMSRedelivered());
150    }
151
152    public void configure(Broker broker,Topic topic) {
153        baseConfiguration(broker,topic);
154        if (dispatchPolicy != null) {
155            topic.setDispatchPolicy(dispatchPolicy);
156        }
157        topic.setDeadLetterStrategy(getDeadLetterStrategy());
158        if (subscriptionRecoveryPolicy != null) {
159            SubscriptionRecoveryPolicy srp = subscriptionRecoveryPolicy.copy();
160            srp.setBroker(broker);
161            topic.setSubscriptionRecoveryPolicy(srp);
162        }
163        if (memoryLimit > 0) {
164            topic.getMemoryUsage().setLimit(memoryLimit);
165        }
166        topic.setLazyDispatch(isLazyDispatch());
167    }
168
169    public void update(Topic topic) {
170        baseUpdate(topic);
171        if (memoryLimit > 0) {
172            topic.getMemoryUsage().setLimit(memoryLimit);
173        }
174        topic.setLazyDispatch(isLazyDispatch());
175    }
176
177    // attributes that can change on the fly
178    public void baseUpdate(BaseDestination destination) {
179        destination.setProducerFlowControl(isProducerFlowControl());
180        destination.setAlwaysRetroactive(isAlwaysRetroactive());
181        destination.setBlockedProducerWarningInterval(getBlockedProducerWarningInterval());
182
183        destination.setMaxPageSize(getMaxPageSize());
184        destination.setMaxBrowsePageSize(getMaxBrowsePageSize());
185
186        destination.setMinimumMessageSize((int) getMinimumMessageSize());
187        destination.setMaxExpirePageSize(getMaxExpirePageSize());
188        destination.setCursorMemoryHighWaterMark(getCursorMemoryHighWaterMark());
189        destination.setStoreUsageHighWaterMark(getStoreUsageHighWaterMark());
190
191        destination.setGcIfInactive(isGcInactiveDestinations());
192        destination.setGcWithNetworkConsumers(isGcWithNetworkConsumers());
193        destination.setInactiveTimeoutBeforeGC(getInactiveTimeoutBeforeGC());
194        destination.setReduceMemoryFootprint(isReduceMemoryFootprint());
195        destination.setDoOptimzeMessageStorage(isDoOptimzeMessageStorage());
196        destination.setOptimizeMessageStoreInFlightLimit(getOptimizeMessageStoreInFlightLimit());
197
198        destination.setAdvisoryForConsumed(isAdvisoryForConsumed());
199        destination.setAdvisoryForDelivery(isAdvisoryForDelivery());
200        destination.setAdvisoryForDiscardingMessages(isAdvisoryForDiscardingMessages());
201        destination.setAdvisoryForSlowConsumers(isAdvisoryForSlowConsumers());
202        destination.setAdvisoryForFastProducers(isAdvisoryForFastProducers());
203        destination.setAdvisoryWhenFull(isAdvisoryWhenFull());
204        destination.setIncludeBodyForAdvisory(isIncludeBodyForAdvisory());
205        destination.setSendAdvisoryIfNoConsumers(isSendAdvisoryIfNoConsumers());
206    }
207
208    public void baseConfiguration(Broker broker, BaseDestination destination) {
209        baseUpdate(destination);
210        destination.setEnableAudit(isEnableAudit());
211        destination.setMaxAuditDepth(getMaxQueueAuditDepth());
212        destination.setMaxProducersToAudit(getMaxProducersToAudit());
213        destination.setUseCache(isUseCache());
214        destination.setExpireMessagesPeriod(getExpireMessagesPeriod());
215        SlowConsumerStrategy scs = getSlowConsumerStrategy();
216        if (scs != null) {
217            scs.setBrokerService(broker);
218            scs.addDestination(destination);
219        }
220        destination.setSlowConsumerStrategy(scs);
221        destination.setPrioritizedMessages(isPrioritizedMessages());
222    }
223
224    public void configure(Broker broker, SystemUsage memoryManager, TopicSubscription subscription) {
225        configurePrefetch(subscription);
226        if (pendingMessageLimitStrategy != null) {
227            int value = pendingMessageLimitStrategy.getMaximumPendingMessageLimit(subscription);
228            int consumerLimit = subscription.getInfo().getMaximumPendingMessageLimit();
229            if (consumerLimit > 0) {
230                if (value < 0 || consumerLimit < value) {
231                    value = consumerLimit;
232                }
233            }
234            if (value >= 0) {
235                LOG.debug("Setting the maximumPendingMessages size to: {} for consumer: {}", value, subscription.getInfo().getConsumerId());
236                subscription.setMaximumPendingMessages(value);
237            }
238        }
239        if (messageEvictionStrategy != null) {
240            subscription.setMessageEvictionStrategy(messageEvictionStrategy);
241        }
242        if (pendingSubscriberPolicy != null) {
243            String name = subscription.getContext().getClientId() + "_" + subscription.getConsumerInfo().getConsumerId();
244            int maxBatchSize = subscription.getConsumerInfo().getPrefetchSize();
245            subscription.setMatched(pendingSubscriberPolicy.getSubscriberPendingMessageCursor(broker,name, maxBatchSize,subscription));
246        }
247        if (enableAudit) {
248            subscription.setEnableAudit(enableAudit);
249            subscription.setMaxProducersToAudit(maxProducersToAudit);
250            subscription.setMaxAuditDepth(maxAuditDepth);
251        }
252    }
253
254    public void configure(Broker broker, SystemUsage memoryManager, DurableTopicSubscription sub) {
255        String clientId = sub.getSubscriptionKey().getClientId();
256        String subName = sub.getSubscriptionKey().getSubscriptionName();
257        sub.setCursorMemoryHighWaterMark(getCursorMemoryHighWaterMark());
258        configurePrefetch(sub);
259        if (pendingDurableSubscriberPolicy != null) {
260            PendingMessageCursor cursor = pendingDurableSubscriberPolicy.getSubscriberPendingMessageCursor(broker,clientId, subName,sub.getPrefetchSize(),sub);
261            cursor.setSystemUsage(memoryManager);
262            sub.setPending(cursor);
263        }
264        int auditDepth = getMaxAuditDepth();
265        if (auditDepth == BaseDestination.MAX_AUDIT_DEPTH && this.isPrioritizedMessages()) {
266            sub.setMaxAuditDepth(auditDepth * 10);
267        } else {
268            sub.setMaxAuditDepth(auditDepth);
269        }
270        sub.setMaxProducersToAudit(getMaxProducersToAudit());
271        sub.setUsePrefetchExtension(isUsePrefetchExtension());
272    }
273
274    public void configure(Broker broker, SystemUsage memoryManager, QueueBrowserSubscription sub) {
275        configurePrefetch(sub);
276        sub.setCursorMemoryHighWaterMark(getCursorMemoryHighWaterMark());
277        sub.setUsePrefetchExtension(isUsePrefetchExtension());
278
279        // TODO
280        // We currently need an infinite audit because of the way that browser dispatch
281        // is done.  We should refactor the browsers to better handle message dispatch so
282        // we can remove this and perform a more efficient dispatch.
283        sub.setMaxProducersToAudit(Integer.MAX_VALUE);
284        sub.setMaxAuditDepth(Short.MAX_VALUE);
285
286        // part solution - dispatching to browsers needs to be restricted
287        sub.setMaxMessages(getMaxBrowsePageSize());
288    }
289
290    public void configure(Broker broker, SystemUsage memoryManager, QueueSubscription sub) {
291        configurePrefetch(sub);
292        sub.setCursorMemoryHighWaterMark(getCursorMemoryHighWaterMark());
293        sub.setUsePrefetchExtension(isUsePrefetchExtension());
294        sub.setMaxProducersToAudit(getMaxProducersToAudit());
295    }
296
297    public void configurePrefetch(Subscription subscription) {
298
299        final int currentPrefetch = subscription.getConsumerInfo().getPrefetchSize();
300        if (subscription instanceof QueueBrowserSubscription) {
301            if (currentPrefetch == ActiveMQPrefetchPolicy.DEFAULT_QUEUE_BROWSER_PREFETCH) {
302                ((QueueBrowserSubscription) subscription).setPrefetchSize(getQueueBrowserPrefetch());
303            }
304        } else if (subscription instanceof QueueSubscription) {
305            if (currentPrefetch == ActiveMQPrefetchPolicy.DEFAULT_QUEUE_PREFETCH) {
306                ((QueueSubscription) subscription).setPrefetchSize(getQueuePrefetch());
307            }
308        } else if (subscription instanceof DurableTopicSubscription) {
309            if (currentPrefetch == ActiveMQPrefetchPolicy.DEFAULT_DURABLE_TOPIC_PREFETCH ||
310                    subscription.getConsumerInfo().getPrefetchSize() == ActiveMQPrefetchPolicy.DEFAULT_OPTIMIZE_DURABLE_TOPIC_PREFETCH) {
311                ((DurableTopicSubscription)subscription).setPrefetchSize(getDurableTopicPrefetch());
312            }
313        } else if (subscription instanceof TopicSubscription) {
314            if (currentPrefetch == ActiveMQPrefetchPolicy.DEFAULT_TOPIC_PREFETCH) {
315                ((TopicSubscription) subscription).setPrefetchSize(getTopicPrefetch());
316            }
317        }
318        if (currentPrefetch != 0 && subscription.getPrefetchSize() == 0) {
319            // tell the sub so that it can issue a pull request
320            subscription.updateConsumerPrefetch(0);
321        }
322    }
323
324    // Properties
325    // -------------------------------------------------------------------------
326    public DispatchPolicy getDispatchPolicy() {
327        return dispatchPolicy;
328    }
329
330    public void setDispatchPolicy(DispatchPolicy policy) {
331        this.dispatchPolicy = policy;
332    }
333
334    public SubscriptionRecoveryPolicy getSubscriptionRecoveryPolicy() {
335        return subscriptionRecoveryPolicy;
336    }
337
338    public void setSubscriptionRecoveryPolicy(SubscriptionRecoveryPolicy subscriptionRecoveryPolicy) {
339        this.subscriptionRecoveryPolicy = subscriptionRecoveryPolicy;
340    }
341
342    public boolean isSendAdvisoryIfNoConsumers() {
343        return sendAdvisoryIfNoConsumers;
344    }
345
346    /**
347     * Sends an advisory message if a non-persistent message is sent and there
348     * are no active consumers
349     */
350    public void setSendAdvisoryIfNoConsumers(boolean sendAdvisoryIfNoConsumers) {
351        this.sendAdvisoryIfNoConsumers = sendAdvisoryIfNoConsumers;
352    }
353
354    public DeadLetterStrategy getDeadLetterStrategy() {
355        return deadLetterStrategy;
356    }
357
358    /**
359     * Sets the policy used to determine which dead letter queue destination
360     * should be used
361     */
362    public void setDeadLetterStrategy(DeadLetterStrategy deadLetterStrategy) {
363        this.deadLetterStrategy = deadLetterStrategy;
364    }
365
366    public PendingMessageLimitStrategy getPendingMessageLimitStrategy() {
367        return pendingMessageLimitStrategy;
368    }
369
370    /**
371     * Sets the strategy to calculate the maximum number of messages that are
372     * allowed to be pending on consumers (in addition to their prefetch sizes).
373     * Once the limit is reached, non-durable topics can then start discarding
374     * old messages. This allows us to keep dispatching messages to slow
375     * consumers while not blocking fast consumers and discarding the messages
376     * oldest first.
377     */
378    public void setPendingMessageLimitStrategy(PendingMessageLimitStrategy pendingMessageLimitStrategy) {
379        this.pendingMessageLimitStrategy = pendingMessageLimitStrategy;
380    }
381
382    public MessageEvictionStrategy getMessageEvictionStrategy() {
383        return messageEvictionStrategy;
384    }
385
386    /**
387     * Sets the eviction strategy used to decide which message to evict when the
388     * slow consumer needs to discard messages
389     */
390    public void setMessageEvictionStrategy(MessageEvictionStrategy messageEvictionStrategy) {
391        this.messageEvictionStrategy = messageEvictionStrategy;
392    }
393
394    public long getMemoryLimit() {
395        return memoryLimit;
396    }
397
398    /**
399     * When set using Xbean, values of the form "20 Mb", "1024kb", and "1g" can be used
400     * @org.apache.xbean.Property propertyEditor="org.apache.activemq.util.MemoryPropertyEditor"
401     */
402    public void setMemoryLimit(long memoryLimit) {
403        this.memoryLimit = memoryLimit;
404    }
405
406    public MessageGroupMapFactory getMessageGroupMapFactory() {
407        if (messageGroupMapFactory == null) {
408            try {
409            messageGroupMapFactory = GroupFactoryFinder.createMessageGroupMapFactory(getMessageGroupMapFactoryType());
410            }catch(Exception e){
411                LOG.error("Failed to create message group Factory ",e);
412            }
413        }
414        return messageGroupMapFactory;
415    }
416
417    /**
418     * Sets the factory used to create new instances of {MessageGroupMap} used
419     * to implement the <a
420     * href="http://activemq.apache.org/message-groups.html">Message Groups</a>
421     * functionality.
422     */
423    public void setMessageGroupMapFactory(MessageGroupMapFactory messageGroupMapFactory) {
424        this.messageGroupMapFactory = messageGroupMapFactory;
425    }
426
427
428    public String getMessageGroupMapFactoryType() {
429        return messageGroupMapFactoryType;
430    }
431
432    public void setMessageGroupMapFactoryType(String messageGroupMapFactoryType) {
433        this.messageGroupMapFactoryType = messageGroupMapFactoryType;
434    }
435
436
437    /**
438     * @return the pendingDurableSubscriberPolicy
439     */
440    public PendingDurableSubscriberMessageStoragePolicy getPendingDurableSubscriberPolicy() {
441        return this.pendingDurableSubscriberPolicy;
442    }
443
444    /**
445     * @param pendingDurableSubscriberPolicy the pendingDurableSubscriberPolicy
446     *                to set
447     */
448    public void setPendingDurableSubscriberPolicy(PendingDurableSubscriberMessageStoragePolicy pendingDurableSubscriberPolicy) {
449        this.pendingDurableSubscriberPolicy = pendingDurableSubscriberPolicy;
450    }
451
452    /**
453     * @return the pendingQueuePolicy
454     */
455    public PendingQueueMessageStoragePolicy getPendingQueuePolicy() {
456        return this.pendingQueuePolicy;
457    }
458
459    /**
460     * @param pendingQueuePolicy the pendingQueuePolicy to set
461     */
462    public void setPendingQueuePolicy(PendingQueueMessageStoragePolicy pendingQueuePolicy) {
463        this.pendingQueuePolicy = pendingQueuePolicy;
464    }
465
466    /**
467     * @return the pendingSubscriberPolicy
468     */
469    public PendingSubscriberMessageStoragePolicy getPendingSubscriberPolicy() {
470        return this.pendingSubscriberPolicy;
471    }
472
473    /**
474     * @param pendingSubscriberPolicy the pendingSubscriberPolicy to set
475     */
476    public void setPendingSubscriberPolicy(PendingSubscriberMessageStoragePolicy pendingSubscriberPolicy) {
477        this.pendingSubscriberPolicy = pendingSubscriberPolicy;
478    }
479
480    /**
481     * @return true if producer flow control enabled
482     */
483    public boolean isProducerFlowControl() {
484        return producerFlowControl;
485    }
486
487    /**
488     * @param producerFlowControl
489     */
490    public void setProducerFlowControl(boolean producerFlowControl) {
491        this.producerFlowControl = producerFlowControl;
492    }
493
494    /**
495     * @return true if topic is always retroactive
496     */
497    public boolean isAlwaysRetroactive() {
498        return alwaysRetroactive;
499    }
500
501    /**
502     * @param alwaysRetroactive
503     */
504    public void setAlwaysRetroactive(boolean alwaysRetroactive) {
505        this.alwaysRetroactive = alwaysRetroactive;
506    }
507
508
509    /**
510     * Set's the interval at which warnings about producers being blocked by
511     * resource usage will be triggered. Values of 0 or less will disable
512     * warnings
513     *
514     * @param blockedProducerWarningInterval the interval at which warning about
515     *            blocked producers will be triggered.
516     */
517    public void setBlockedProducerWarningInterval(long blockedProducerWarningInterval) {
518        this.blockedProducerWarningInterval = blockedProducerWarningInterval;
519    }
520
521    /**
522     *
523     * @return the interval at which warning about blocked producers will be
524     *         triggered.
525     */
526    public long getBlockedProducerWarningInterval() {
527        return blockedProducerWarningInterval;
528    }
529
530    /**
531     * @return the maxProducersToAudit
532     */
533    public int getMaxProducersToAudit() {
534        return maxProducersToAudit;
535    }
536
537    /**
538     * @param maxProducersToAudit the maxProducersToAudit to set
539     */
540    public void setMaxProducersToAudit(int maxProducersToAudit) {
541        this.maxProducersToAudit = maxProducersToAudit;
542    }
543
544    /**
545     * @return the maxAuditDepth
546     */
547    public int getMaxAuditDepth() {
548        return maxAuditDepth;
549    }
550
551    /**
552     * @param maxAuditDepth the maxAuditDepth to set
553     */
554    public void setMaxAuditDepth(int maxAuditDepth) {
555        this.maxAuditDepth = maxAuditDepth;
556    }
557
558    /**
559     * @return the enableAudit
560     */
561    public boolean isEnableAudit() {
562        return enableAudit;
563    }
564
565    /**
566     * @param enableAudit the enableAudit to set
567     */
568    public void setEnableAudit(boolean enableAudit) {
569        this.enableAudit = enableAudit;
570    }
571
572    public int getMaxQueueAuditDepth() {
573        return maxQueueAuditDepth;
574    }
575
576    public void setMaxQueueAuditDepth(int maxQueueAuditDepth) {
577        this.maxQueueAuditDepth = maxQueueAuditDepth;
578    }
579
580    public boolean isOptimizedDispatch() {
581        return optimizedDispatch;
582    }
583
584    public void setOptimizedDispatch(boolean optimizedDispatch) {
585        this.optimizedDispatch = optimizedDispatch;
586    }
587
588    public int getMaxPageSize() {
589        return maxPageSize;
590    }
591
592    public void setMaxPageSize(int maxPageSize) {
593        this.maxPageSize = maxPageSize;
594    }
595
596    public int getMaxBrowsePageSize() {
597        return maxBrowsePageSize;
598    }
599
600    public void setMaxBrowsePageSize(int maxPageSize) {
601        this.maxBrowsePageSize = maxPageSize;
602    }
603
604    public boolean isUseCache() {
605        return useCache;
606    }
607
608    public void setUseCache(boolean useCache) {
609        this.useCache = useCache;
610    }
611
612    public long getMinimumMessageSize() {
613        return minimumMessageSize;
614    }
615
616    public void setMinimumMessageSize(long minimumMessageSize) {
617        this.minimumMessageSize = minimumMessageSize;
618    }
619
620    public boolean isUseConsumerPriority() {
621        return useConsumerPriority;
622    }
623
624    public void setUseConsumerPriority(boolean useConsumerPriority) {
625        this.useConsumerPriority = useConsumerPriority;
626    }
627
628    public boolean isStrictOrderDispatch() {
629        return strictOrderDispatch;
630    }
631
632    public void setStrictOrderDispatch(boolean strictOrderDispatch) {
633        this.strictOrderDispatch = strictOrderDispatch;
634    }
635
636    public boolean isLazyDispatch() {
637        return lazyDispatch;
638    }
639
640    public void setLazyDispatch(boolean lazyDispatch) {
641        this.lazyDispatch = lazyDispatch;
642    }
643
644    public int getTimeBeforeDispatchStarts() {
645        return timeBeforeDispatchStarts;
646    }
647
648    public void setTimeBeforeDispatchStarts(int timeBeforeDispatchStarts) {
649        this.timeBeforeDispatchStarts = timeBeforeDispatchStarts;
650    }
651
652    public int getConsumersBeforeDispatchStarts() {
653        return consumersBeforeDispatchStarts;
654    }
655
656    public void setConsumersBeforeDispatchStarts(int consumersBeforeDispatchStarts) {
657        this.consumersBeforeDispatchStarts = consumersBeforeDispatchStarts;
658    }
659
660    /**
661     * @return the advisoryForSlowConsumers
662     */
663    public boolean isAdvisoryForSlowConsumers() {
664        return advisoryForSlowConsumers;
665    }
666
667    /**
668     * @param advisoryForSlowConsumers the advisoryForSlowConsumers to set
669     */
670    public void setAdvisoryForSlowConsumers(boolean advisoryForSlowConsumers) {
671        this.advisoryForSlowConsumers = advisoryForSlowConsumers;
672    }
673
674    /**
675     * @return the advisoryForDiscardingMessages
676     */
677    public boolean isAdvisoryForDiscardingMessages() {
678        return advisoryForDiscardingMessages;
679    }
680
681    /**
682     * @param advisoryForDiscardingMessages the advisoryForDiscardingMessages to set
683     */
684    public void setAdvisoryForDiscardingMessages(
685            boolean advisoryForDiscardingMessages) {
686        this.advisoryForDiscardingMessages = advisoryForDiscardingMessages;
687    }
688
689    /**
690     * @return the advisoryWhenFull
691     */
692    public boolean isAdvisoryWhenFull() {
693        return advisoryWhenFull;
694    }
695
696    /**
697     * @param advisoryWhenFull the advisoryWhenFull to set
698     */
699    public void setAdvisoryWhenFull(boolean advisoryWhenFull) {
700        this.advisoryWhenFull = advisoryWhenFull;
701    }
702
703    /**
704     * @return the advisoryForDelivery
705     */
706    public boolean isAdvisoryForDelivery() {
707        return advisoryForDelivery;
708    }
709
710    /**
711     * @param advisoryForDelivery the advisoryForDelivery to set
712     */
713    public void setAdvisoryForDelivery(boolean advisoryForDelivery) {
714        this.advisoryForDelivery = advisoryForDelivery;
715    }
716
717    /**
718     * @return the advisoryForConsumed
719     */
720    public boolean isAdvisoryForConsumed() {
721        return advisoryForConsumed;
722    }
723
724    /**
725     * @param advisoryForConsumed the advisoryForConsumed to set
726     */
727    public void setAdvisoryForConsumed(boolean advisoryForConsumed) {
728        this.advisoryForConsumed = advisoryForConsumed;
729    }
730
731    /**
732     * @return the advisdoryForFastProducers
733     */
734    public boolean isAdvisoryForFastProducers() {
735        return advisoryForFastProducers;
736    }
737
738    /**
739     * @param advisoryForFastProducers the advisdoryForFastProducers to set
740     */
741    public void setAdvisoryForFastProducers(boolean advisoryForFastProducers) {
742        this.advisoryForFastProducers = advisoryForFastProducers;
743    }
744
745    /**
746     * Returns true if the original message body should be included when applicable
747     * for advisory messages
748     *
749     * @return
750     */
751    public boolean isIncludeBodyForAdvisory() {
752        return includeBodyForAdvisory;
753    }
754
755    /**
756     * Sets if the original message body should be included when applicable
757     * for advisory messages
758     *
759     * @param includeBodyForAdvisory
760     */
761    public void setIncludeBodyForAdvisory(boolean includeBodyForAdvisory) {
762        this.includeBodyForAdvisory = includeBodyForAdvisory;
763    }
764
765    public void setMaxExpirePageSize(int maxExpirePageSize) {
766        this.maxExpirePageSize = maxExpirePageSize;
767    }
768
769    public int getMaxExpirePageSize() {
770        return maxExpirePageSize;
771    }
772
773    public void setExpireMessagesPeriod(long expireMessagesPeriod) {
774        this.expireMessagesPeriod = expireMessagesPeriod;
775    }
776
777    public long getExpireMessagesPeriod() {
778        return expireMessagesPeriod;
779    }
780
781    /**
782     * Get the queuePrefetch
783     * @return the queuePrefetch
784     */
785    public int getQueuePrefetch() {
786        return this.queuePrefetch;
787    }
788
789    /**
790     * Set the queuePrefetch
791     * @param queuePrefetch the queuePrefetch to set
792     */
793    public void setQueuePrefetch(int queuePrefetch) {
794        this.queuePrefetch = queuePrefetch;
795    }
796
797    /**
798     * Get the queueBrowserPrefetch
799     * @return the queueBrowserPrefetch
800     */
801    public int getQueueBrowserPrefetch() {
802        return this.queueBrowserPrefetch;
803    }
804
805    /**
806     * Set the queueBrowserPrefetch
807     * @param queueBrowserPrefetch the queueBrowserPrefetch to set
808     */
809    public void setQueueBrowserPrefetch(int queueBrowserPrefetch) {
810        this.queueBrowserPrefetch = queueBrowserPrefetch;
811    }
812
813    /**
814     * Get the topicPrefetch
815     * @return the topicPrefetch
816     */
817    public int getTopicPrefetch() {
818        return this.topicPrefetch;
819    }
820
821    /**
822     * Set the topicPrefetch
823     * @param topicPrefetch the topicPrefetch to set
824     */
825    public void setTopicPrefetch(int topicPrefetch) {
826        this.topicPrefetch = topicPrefetch;
827    }
828
829    /**
830     * Get the durableTopicPrefetch
831     * @return the durableTopicPrefetch
832     */
833    public int getDurableTopicPrefetch() {
834        return this.durableTopicPrefetch;
835    }
836
837    /**
838     * Set the durableTopicPrefetch
839     * @param durableTopicPrefetch the durableTopicPrefetch to set
840     */
841    public void setDurableTopicPrefetch(int durableTopicPrefetch) {
842        this.durableTopicPrefetch = durableTopicPrefetch;
843    }
844
845    public boolean isUsePrefetchExtension() {
846        return this.usePrefetchExtension;
847    }
848
849    public void setUsePrefetchExtension(boolean usePrefetchExtension) {
850        this.usePrefetchExtension = usePrefetchExtension;
851    }
852
853    public int getCursorMemoryHighWaterMark() {
854        return this.cursorMemoryHighWaterMark;
855    }
856
857    public void setCursorMemoryHighWaterMark(int cursorMemoryHighWaterMark) {
858        this.cursorMemoryHighWaterMark = cursorMemoryHighWaterMark;
859    }
860
861    public void setStoreUsageHighWaterMark(int storeUsageHighWaterMark) {
862        this.storeUsageHighWaterMark = storeUsageHighWaterMark;
863    }
864
865    public int getStoreUsageHighWaterMark() {
866        return storeUsageHighWaterMark;
867    }
868
869    public void setSlowConsumerStrategy(SlowConsumerStrategy slowConsumerStrategy) {
870        this.slowConsumerStrategy = slowConsumerStrategy;
871    }
872
873    public SlowConsumerStrategy getSlowConsumerStrategy() {
874        return this.slowConsumerStrategy;
875    }
876
877
878    public boolean isPrioritizedMessages() {
879        return this.prioritizedMessages;
880    }
881
882    public void setPrioritizedMessages(boolean prioritizedMessages) {
883        this.prioritizedMessages = prioritizedMessages;
884    }
885
886    public void setAllConsumersExclusiveByDefault(boolean allConsumersExclusiveByDefault) {
887        this.allConsumersExclusiveByDefault = allConsumersExclusiveByDefault;
888    }
889
890    public boolean isAllConsumersExclusiveByDefault() {
891        return allConsumersExclusiveByDefault;
892    }
893
894    public boolean isGcInactiveDestinations() {
895        return this.gcInactiveDestinations;
896    }
897
898    public void setGcInactiveDestinations(boolean gcInactiveDestinations) {
899        this.gcInactiveDestinations = gcInactiveDestinations;
900    }
901
902    /**
903     * @return the amount of time spent inactive before GC of the destination kicks in.
904     *
905     * @deprecated use getInactiveTimeoutBeforeGC instead.
906     */
907    @Deprecated
908    public long getInactiveTimoutBeforeGC() {
909        return getInactiveTimeoutBeforeGC();
910    }
911
912    /**
913     * Sets the amount of time a destination is inactive before it is marked for GC
914     *
915     * @param inactiveTimoutBeforeGC
916     *        time in milliseconds to configure as the inactive timeout.
917     *
918     * @deprecated use getInactiveTimeoutBeforeGC instead.
919     */
920    @Deprecated
921    public void setInactiveTimoutBeforeGC(long inactiveTimoutBeforeGC) {
922        setInactiveTimeoutBeforeGC(inactiveTimoutBeforeGC);
923    }
924
925    /**
926     * @return the amount of time spent inactive before GC of the destination kicks in.
927     */
928    public long getInactiveTimeoutBeforeGC() {
929        return this.inactiveTimeoutBeforeGC;
930    }
931
932    /**
933     * Sets the amount of time a destination is inactive before it is marked for GC
934     *
935     * @param inactiveTimoutBeforeGC
936     *        time in milliseconds to configure as the inactive timeout.
937     */
938    public void setInactiveTimeoutBeforeGC(long inactiveTimeoutBeforeGC) {
939        this.inactiveTimeoutBeforeGC = inactiveTimeoutBeforeGC;
940    }
941
942    public void setGcWithNetworkConsumers(boolean gcWithNetworkConsumers) {
943        this.gcWithNetworkConsumers = gcWithNetworkConsumers;
944    }
945
946    public boolean isGcWithNetworkConsumers() {
947        return gcWithNetworkConsumers;
948    }
949
950    public boolean isReduceMemoryFootprint() {
951        return reduceMemoryFootprint;
952    }
953
954    public void setReduceMemoryFootprint(boolean reduceMemoryFootprint) {
955        this.reduceMemoryFootprint = reduceMemoryFootprint;
956    }
957
958    public void setNetworkBridgeFilterFactory(NetworkBridgeFilterFactory networkBridgeFilterFactory) {
959        this.networkBridgeFilterFactory = networkBridgeFilterFactory;
960    }
961
962    public NetworkBridgeFilterFactory getNetworkBridgeFilterFactory() {
963        return networkBridgeFilterFactory;
964    }
965
966    public boolean isDoOptimzeMessageStorage() {
967        return doOptimzeMessageStorage;
968    }
969
970    public void setDoOptimzeMessageStorage(boolean doOptimzeMessageStorage) {
971        this.doOptimzeMessageStorage = doOptimzeMessageStorage;
972    }
973
974    public int getOptimizeMessageStoreInFlightLimit() {
975        return optimizeMessageStoreInFlightLimit;
976    }
977
978    public void setOptimizeMessageStoreInFlightLimit(int optimizeMessageStoreInFlightLimit) {
979        this.optimizeMessageStoreInFlightLimit = optimizeMessageStoreInFlightLimit;
980    }
981
982    public void setPersistJMSRedelivered(boolean val) {
983        this.persistJMSRedelivered = val;
984    }
985
986    public boolean isPersistJMSRedelivered() {
987        return persistJMSRedelivered;
988    }
989
990    public int getMaxDestinations() {
991        return maxDestinations;
992    }
993
994    /**
995     * Sets the maximum number of destinations that can be created
996     *
997     * @param maxDestinations
998     *            maximum number of destinations
999     */
1000    public void setMaxDestinations(int maxDestinations) {
1001        this.maxDestinations = maxDestinations;
1002    }
1003
1004    @Override
1005    public String toString() {
1006        return "PolicyEntry [" + destination + "]";
1007    }
1008}