mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3986 - improve test, copy prefetch policies on managed connection factory
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1379414 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eea9fca04d
commit
1e57750dd6
|
@ -56,23 +56,42 @@ public class ActiveMQManagedConnectionFactory extends ActiveMQConnectionSupport
|
||||||
{
|
{
|
||||||
if ( log.isDebugEnabled() ) {
|
if ( log.isDebugEnabled() ) {
|
||||||
log.debug("copying standard ResourceAdapter configuration properties");
|
log.debug("copying standard ResourceAdapter configuration properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMQConnectionRequestInfo baseInfo = ((MessageResourceAdapter) adapter).getInfo().copy();
|
ActiveMQConnectionRequestInfo baseInfo = ((MessageResourceAdapter) adapter).getInfo().copy();
|
||||||
if (getClientid() == null) {
|
if (getClientid() == null) {
|
||||||
setClientid(baseInfo.getClientid());
|
setClientid(baseInfo.getClientid());
|
||||||
}
|
}
|
||||||
if (getPassword() == null) {
|
if (getPassword() == null) {
|
||||||
setPassword(baseInfo.getPassword());
|
setPassword(baseInfo.getPassword());
|
||||||
}
|
}
|
||||||
if (getServerUrl() == null) {
|
if (getServerUrl() == null) {
|
||||||
setServerUrl(baseInfo.getServerUrl());
|
setServerUrl(baseInfo.getServerUrl());
|
||||||
}
|
}
|
||||||
if (getUseInboundSession() == null) {
|
if (getUseInboundSession() == null) {
|
||||||
setUseInboundSession(baseInfo.getUseInboundSession());
|
setUseInboundSession(baseInfo.getUseInboundSession());
|
||||||
}
|
}
|
||||||
if (getUserName() == null) {
|
if (getUserName() == null) {
|
||||||
setUserName(baseInfo.getUserName());
|
setUserName(baseInfo.getUserName());
|
||||||
}
|
}
|
||||||
|
if (getDurableTopicPrefetch() != null) {
|
||||||
|
setDurableTopicPrefetch(baseInfo.getDurableTopicPrefetch());
|
||||||
|
}
|
||||||
|
if (getOptimizeDurableTopicPrefetch() != null) {
|
||||||
|
setOptimizeDurableTopicPrefetch(baseInfo.getOptimizeDurableTopicPrefetch());
|
||||||
|
}
|
||||||
|
if (getQueuePrefetch() != null) {
|
||||||
|
setQueuePrefetch(baseInfo.getQueuePrefetch());
|
||||||
|
}
|
||||||
|
if (getQueueBrowserPrefetch() != null) {
|
||||||
|
setQueueBrowserPrefetch(baseInfo.getQueueBrowserPrefetch());
|
||||||
|
}
|
||||||
|
if (getTopicPrefetch() != null) {
|
||||||
|
setTopicPrefetch(baseInfo.getTopicPrefetch());
|
||||||
|
}
|
||||||
|
if (getInputStreamPrefetch() != null) {
|
||||||
|
setInputStreamPrefetch(baseInfo.getInputStreamPrefetch());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,14 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.Timer;
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.jms.TopicSubscriber;
|
import javax.jms.TopicSubscriber;
|
||||||
|
import javax.resource.spi.BootstrapContext;
|
||||||
|
import javax.resource.spi.UnavailableException;
|
||||||
|
import javax.resource.spi.XATerminator;
|
||||||
|
import javax.resource.spi.work.WorkManager;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.activemq.ActiveMQConnection;
|
import org.apache.activemq.ActiveMQConnection;
|
||||||
|
@ -82,19 +87,22 @@ public class ActiveMQConnectionFactoryTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOptimizeDurablePrefetch() throws Exception {
|
public void testOptimizeDurablePrefetch() throws Exception {
|
||||||
ActiveMQConnectionRequestInfo info = new ActiveMQConnectionRequestInfo();
|
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
|
||||||
info.setServerUrl(url);
|
ra.setServerUrl(url);
|
||||||
info.setUserName(user);
|
ra.setUserName(user);
|
||||||
info.setPassword(pwd);
|
ra.setPassword(pwd);
|
||||||
info.setOptimizeDurableTopicPrefetch(new Integer(500));
|
|
||||||
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(mcf, new ConnectionManagerAdapter(), info);
|
ra.setOptimizeDurableTopicPrefetch(0);
|
||||||
Connection con = factory.createConnection("defaultUser", "defaultPassword");
|
ra.setDurableTopicPrefetch(0);
|
||||||
|
|
||||||
|
Connection con = ra.makeConnection();
|
||||||
|
|
||||||
con.setClientID("x");
|
con.setClientID("x");
|
||||||
Session sess = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
Session sess = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
TopicSubscriber sub = sess.createDurableSubscriber(sess.createTopic("TEST"), "x");
|
TopicSubscriber sub = sess.createDurableSubscriber(sess.createTopic("TEST"), "x");
|
||||||
con.start();
|
con.start();
|
||||||
|
|
||||||
assertEquals(500, ((ActiveMQTopicSubscriber)sub).getPrefetchNumber());
|
assertEquals(0, ((ActiveMQTopicSubscriber)sub).getPrefetchNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue