Enforce max prefetch limit even in setAll and set inputstream using all
value.
This commit is contained in:
Timothy Bish 2014-02-04 10:38:42 -05:00
parent 5a80cee960
commit 9eb7fb9062
1 changed files with 30 additions and 22 deletions

View File

@ -17,6 +17,7 @@
package org.apache.activemq; package org.apache.activemq;
import java.io.Serializable; import java.io.Serializable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -28,6 +29,7 @@ import org.slf4j.LoggerFactory;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ActiveMQPrefetchPolicy extends Object implements Serializable { public class ActiveMQPrefetchPolicy extends Object implements Serializable {
public static final int MAX_PREFETCH_SIZE = Short.MAX_VALUE; public static final int MAX_PREFETCH_SIZE = Short.MAX_VALUE;
public static final int DEFAULT_QUEUE_PREFETCH = 1000; public static final int DEFAULT_QUEUE_PREFETCH = 1000;
public static final int DEFAULT_QUEUE_BROWSER_PREFETCH = 500; public static final int DEFAULT_QUEUE_BROWSER_PREFETCH = 500;
@ -66,7 +68,8 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
/** /**
* @param durableTopicPrefetch The durableTopicPrefetch to set. * @param durableTopicPrefetch
* The durableTopicPrefetch to set.
*/ */
public void setDurableTopicPrefetch(int durableTopicPrefetch) { public void setDurableTopicPrefetch(int durableTopicPrefetch) {
this.durableTopicPrefetch = getMaxPrefetchLimit(durableTopicPrefetch); this.durableTopicPrefetch = getMaxPrefetchLimit(durableTopicPrefetch);
@ -80,7 +83,8 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
/** /**
* @param queuePrefetch The queuePrefetch to set. * @param queuePrefetch
* The queuePrefetch to set.
*/ */
public void setQueuePrefetch(int queuePrefetch) { public void setQueuePrefetch(int queuePrefetch) {
this.queuePrefetch = getMaxPrefetchLimit(queuePrefetch); this.queuePrefetch = getMaxPrefetchLimit(queuePrefetch);
@ -94,7 +98,8 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
/** /**
* @param queueBrowserPrefetch The queueBrowserPrefetch to set. * @param queueBrowserPrefetch
* The queueBrowserPrefetch to set.
*/ */
public void setQueueBrowserPrefetch(int queueBrowserPrefetch) { public void setQueueBrowserPrefetch(int queueBrowserPrefetch) {
this.queueBrowserPrefetch = getMaxPrefetchLimit(queueBrowserPrefetch); this.queueBrowserPrefetch = getMaxPrefetchLimit(queueBrowserPrefetch);
@ -108,7 +113,8 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
/** /**
* @param topicPrefetch The topicPrefetch to set. * @param topicPrefetch
* The topicPrefetch to set.
*/ */
public void setTopicPrefetch(int topicPrefetch) { public void setTopicPrefetch(int topicPrefetch) {
this.topicPrefetch = getMaxPrefetchLimit(topicPrefetch); this.topicPrefetch = getMaxPrefetchLimit(topicPrefetch);
@ -122,8 +128,8 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
/** /**
* @param optimizeAcknowledgePrefetch The optimizeDurableTopicPrefetch to * @param optimizeAcknowledgePrefetch
* set. * The optimizeDurableTopicPrefetch to set.
*/ */
public void setOptimizeDurableTopicPrefetch(int optimizeAcknowledgePrefetch) { public void setOptimizeDurableTopicPrefetch(int optimizeAcknowledgePrefetch) {
this.optimizeDurableTopicPrefetch = optimizeAcknowledgePrefetch; this.optimizeDurableTopicPrefetch = optimizeAcknowledgePrefetch;
@ -150,22 +156,25 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
public void setAll(int i) { public void setAll(int i) {
this.durableTopicPrefetch = i; this.durableTopicPrefetch = getMaxPrefetchLimit(i);
this.queueBrowserPrefetch = i; this.queueBrowserPrefetch = getMaxPrefetchLimit(i);
this.queuePrefetch = i; this.queuePrefetch = getMaxPrefetchLimit(i);
this.topicPrefetch = i; this.topicPrefetch = getMaxPrefetchLimit(i);
this.inputStreamPrefetch = 1; this.inputStreamPrefetch = getMaxPrefetchLimit(i);
this.optimizeDurableTopicPrefetch = i; this.optimizeDurableTopicPrefetch = getMaxPrefetchLimit(i);
} }
@Deprecated
public int getInputStreamPrefetch() { public int getInputStreamPrefetch() {
return inputStreamPrefetch; return inputStreamPrefetch;
} }
@Deprecated
public void setInputStreamPrefetch(int inputStreamPrefetch) { public void setInputStreamPrefetch(int inputStreamPrefetch) {
this.inputStreamPrefetch = getMaxPrefetchLimit(inputStreamPrefetch); this.inputStreamPrefetch = getMaxPrefetchLimit(inputStreamPrefetch);
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (object instanceof ActiveMQPrefetchPolicy) { if (object instanceof ActiveMQPrefetchPolicy) {
ActiveMQPrefetchPolicy other = (ActiveMQPrefetchPolicy) object; ActiveMQPrefetchPolicy other = (ActiveMQPrefetchPolicy) object;
@ -178,5 +187,4 @@ public class ActiveMQPrefetchPolicy extends Object implements Serializable {
} }
return false; return false;
} }
} }