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