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