diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java index c930b28558..33ff63d8c6 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQConnectionRequestInfo.java @@ -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) { if (inputStreamPrefetch != null) { prefetchPolicy().setInputStreamPrefetch(inputStreamPrefetch.intValue()); diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java index aa71ca1392..00a733af42 100644 --- a/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java +++ b/activemq-ra/src/test/java/org/apache/activemq/ra/ActiveMQConnectionFactoryTest.java @@ -22,8 +22,12 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import javax.jms.Connection; +import javax.jms.Session; +import javax.jms.TopicSubscriber; + import junit.framework.TestCase; 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); } + 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()); + } + }