https://issues.apache.org/jira/browse/AMQ-3986 - optimizeDurablePrefetch with RA adapter

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1376431 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2012-08-23 10:50:36 +00:00
parent 5ed1ce50da
commit 86e9527e1f
2 changed files with 26 additions and 0 deletions

View File

@ -279,6 +279,12 @@ public class ActiveMQConnectionRequestInfo implements ConnectionRequestInfo, Ser
} }
} }
public void setOptimizeDurableTopicPrefetch(Integer optimizeDurableTopicPrefetch) {
if (optimizeDurableTopicPrefetch != null) {
prefetchPolicy().setOptimizeDurableTopicPrefetch(optimizeDurableTopicPrefetch.intValue());
}
}
public void setInputStreamPrefetch(Integer inputStreamPrefetch) { public void setInputStreamPrefetch(Integer inputStreamPrefetch) {
if (inputStreamPrefetch != null) { if (inputStreamPrefetch != null) {
prefetchPolicy().setInputStreamPrefetch(inputStreamPrefetch.intValue()); prefetchPolicy().setInputStreamPrefetch(inputStreamPrefetch.intValue());

View File

@ -22,8 +22,12 @@ import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; import java.io.ObjectOutputStream;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.Session;
import javax.jms.TopicSubscriber;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQTopicSubscriber;
/** /**
* *
@ -77,4 +81,20 @@ public class ActiveMQConnectionFactoryTest extends TestCase {
assertNotNull("Connection object returned by ActiveMQConnectionFactory.createConnection() is null", con); assertNotNull("Connection object returned by ActiveMQConnectionFactory.createConnection() is null", con);
} }
public void testOptimizeDurablePrefetch() throws Exception {
ActiveMQConnectionRequestInfo info = new ActiveMQConnectionRequestInfo();
info.setServerUrl(url);
info.setUserName(user);
info.setPassword(pwd);
info.setOptimizeDurableTopicPrefetch(new Integer(500));
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(mcf, new ConnectionManagerAdapter(), info);
Connection con = factory.createConnection("defaultUser", "defaultPassword");
con.setClientID("x");
Session sess = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber sub = sess.createDurableSubscriber(sess.createTopic("TEST"), "x");
con.start();
assertEquals(500, ((ActiveMQTopicSubscriber)sub).getPrefetchNumber());
}
} }