mirror of https://github.com/apache/activemq.git
set the prefetch to something sensible (this is actually a key bit!)
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@509566 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d0beb32cb8
commit
b0b602121e
|
@ -1,24 +1,21 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
|
||||||
* this work for additional information regarding copyright ownership.
|
* to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
* License. You may obtain a copy of the License at
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* specific language governing permissions and limitations under the License.
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.activemq.bugs;
|
package org.apache.activemq.bugs;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
||||||
|
@ -38,31 +35,20 @@ import org.apache.activemq.test.JmsTopicSendReceiveTest;
|
||||||
* @version $Revision: 1.5 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest{
|
public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest{
|
||||||
|
|
||||||
private static final org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory
|
private static final org.apache.commons.logging.Log log=org.apache.commons.logging.LogFactory
|
||||||
.getLog(JmsDurableTopicSlowReceiveTest.class);
|
.getLog(JmsDurableTopicSlowReceiveTest.class);
|
||||||
|
|
||||||
protected Connection connection2;
|
protected Connection connection2;
|
||||||
|
|
||||||
protected Session session2;
|
protected Session session2;
|
||||||
|
|
||||||
protected Session consumeSession2;
|
protected Session consumeSession2;
|
||||||
|
|
||||||
protected MessageConsumer consumer2;
|
protected MessageConsumer consumer2;
|
||||||
|
|
||||||
protected MessageProducer producer2;
|
protected MessageProducer producer2;
|
||||||
|
|
||||||
protected Destination consumerDestination2;
|
protected Destination consumerDestination2;
|
||||||
|
BrokerService broker;
|
||||||
|
|
||||||
final int NMSG=100;
|
final int NMSG=100;
|
||||||
|
|
||||||
final int MSIZE=256000;
|
final int MSIZE=256000;
|
||||||
|
|
||||||
|
|
||||||
private Connection connection3;
|
private Connection connection3;
|
||||||
|
|
||||||
private Session consumeSession3;
|
private Session consumeSession3;
|
||||||
|
|
||||||
private TopicSubscriber consumer3;
|
private TopicSubscriber consumer3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,13 +58,21 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
|
||||||
*/
|
*/
|
||||||
protected void setUp() throws Exception{
|
protected void setUp() throws Exception{
|
||||||
this.durable=true;
|
this.durable=true;
|
||||||
createBroker();
|
broker=createBroker();
|
||||||
super.setUp();
|
super.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception{
|
||||||
|
super.tearDown();
|
||||||
|
broker.stop();
|
||||||
|
}
|
||||||
|
|
||||||
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception{
|
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception{
|
||||||
ActiveMQConnectionFactory result=new ActiveMQConnectionFactory("vm://localhost");
|
ActiveMQConnectionFactory result=new ActiveMQConnectionFactory("vm://localhost");
|
||||||
|
Properties props=new Properties();
|
||||||
|
props.put("prefetchPolicy.durableTopicPrefetch","5");
|
||||||
|
props.put("prefetchPolicy.optimizeDurableTopicPrefetch","5");
|
||||||
|
result.setProperties(props);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +85,11 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
|
||||||
|
|
||||||
protected void configureBroker(BrokerService answer) throws Exception{
|
protected void configureBroker(BrokerService answer) throws Exception{
|
||||||
//KahaPersistenceAdapter adapter=new KahaPersistenceAdapter(new File("activemq-data/durableTest"));
|
//KahaPersistenceAdapter adapter=new KahaPersistenceAdapter(new File("activemq-data/durableTest"));
|
||||||
//answer.setPersistenceAdapter(adapter);
|
|
||||||
//JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
|
//JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
|
||||||
// answer.setPersistenceAdapter(adapter);
|
// answer.setPersistenceAdapter(adapter);
|
||||||
answer.setDeleteAllMessagesOnStartup(true);
|
answer.setDeleteAllMessagesOnStartup(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if all the messages sent are being received.
|
* Test if all the messages sent are being received.
|
||||||
*
|
*
|
||||||
|
@ -107,46 +99,36 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
|
||||||
connection2=createConnection();
|
connection2=createConnection();
|
||||||
connection2.setClientID("test");
|
connection2.setClientID("test");
|
||||||
connection2.start();
|
connection2.start();
|
||||||
|
consumeSession2=connection2.createSession(false,Session.AUTO_ACKNOWLEDGE);
|
||||||
consumeSession2 = connection2.createSession(false,
|
|
||||||
Session.AUTO_ACKNOWLEDGE);
|
|
||||||
session2=connection2.createSession(false,Session.AUTO_ACKNOWLEDGE);
|
session2=connection2.createSession(false,Session.AUTO_ACKNOWLEDGE);
|
||||||
consumerDestination2=session2.createTopic(getConsumerSubject()+"2");
|
consumerDestination2=session2.createTopic(getConsumerSubject()+"2");
|
||||||
consumer2 = consumeSession2.createDurableSubscriber(
|
consumer2=consumeSession2.createDurableSubscriber((Topic)consumerDestination2,getName());
|
||||||
(Topic) consumerDestination2, getName());
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
consumer2.close();
|
consumer2.close();
|
||||||
connection2.close();
|
connection2.close();
|
||||||
|
|
||||||
new Thread(new Runnable(){
|
new Thread(new Runnable(){
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
try{
|
try{
|
||||||
for(int loop=0;loop<4;loop++){
|
for(int loop=0;loop<4;loop++){
|
||||||
connection2=createConnection();
|
connection2=createConnection();
|
||||||
connection2.start();
|
connection2.start();
|
||||||
session2 = connection2.createSession(false,
|
session2=connection2.createSession(false,Session.AUTO_ACKNOWLEDGE);
|
||||||
Session.AUTO_ACKNOWLEDGE);
|
|
||||||
producer2=session2.createProducer(null);
|
producer2=session2.createProducer(null);
|
||||||
producer2.setDeliveryMode(deliveryMode);
|
producer2.setDeliveryMode(deliveryMode);
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
for(int i=0;i<NMSG/4;i++){
|
for(int i=0;i<NMSG/4;i++){
|
||||||
BytesMessage message = session2
|
BytesMessage message=session2.createBytesMessage();
|
||||||
.createBytesMessage();
|
|
||||||
message.writeBytes(new byte[MSIZE]);
|
message.writeBytes(new byte[MSIZE]);
|
||||||
message.setStringProperty("test","test");
|
message.setStringProperty("test","test");
|
||||||
message.setJMSType("test");
|
message.setJMSType("test");
|
||||||
producer2.send(consumerDestination2,message);
|
producer2.send(consumerDestination2,message);
|
||||||
Thread.sleep(50);
|
Thread.sleep(50);
|
||||||
System.err.println("Sent("+loop+"): "+i);
|
System.err.println("Sent("+loop+"): "+i);
|
||||||
|
|
||||||
}
|
}
|
||||||
producer2.close();
|
producer2.close();
|
||||||
connection2.stop();
|
connection2.stop();
|
||||||
connection2.close();
|
connection2.close();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -156,28 +138,20 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
|
||||||
connection3=createConnection();
|
connection3=createConnection();
|
||||||
connection3.setClientID("test");
|
connection3.setClientID("test");
|
||||||
connection3.start();
|
connection3.start();
|
||||||
consumeSession3 = connection3.createSession(false,
|
consumeSession3=connection3.createSession(false,Session.CLIENT_ACKNOWLEDGE);
|
||||||
Session.CLIENT_ACKNOWLEDGE);
|
consumer3=consumeSession3.createDurableSubscriber((Topic)consumerDestination2,getName());
|
||||||
consumer3 = consumeSession3.createDurableSubscriber(
|
|
||||||
(Topic) consumerDestination2, getName());
|
|
||||||
connection3.close();
|
connection3.close();
|
||||||
|
|
||||||
|
|
||||||
for(int loop=0;loop<4;++loop){
|
for(int loop=0;loop<4;++loop){
|
||||||
|
|
||||||
connection3=createConnection();
|
connection3=createConnection();
|
||||||
connection3.setClientID("test");
|
connection3.setClientID("test");
|
||||||
connection3.start();
|
connection3.start();
|
||||||
consumeSession3 = connection3.createSession(false,
|
consumeSession3=connection3.createSession(false,Session.CLIENT_ACKNOWLEDGE);
|
||||||
Session.CLIENT_ACKNOWLEDGE);
|
consumer3=consumeSession3.createDurableSubscriber((Topic)consumerDestination2,getName());
|
||||||
consumer3 = consumeSession3.createDurableSubscriber(
|
|
||||||
(Topic) consumerDestination2, getName());
|
|
||||||
Message msg=null;
|
Message msg=null;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<NMSG/4;i++){
|
for(i=0;i<NMSG/4;i++){
|
||||||
// System.err.println("Receive...");
|
// System.err.println("Receive...");
|
||||||
msg = consumer3.receive(Integer.MAX_VALUE);
|
msg=consumer3.receive(10000);
|
||||||
if(msg==null)
|
if(msg==null)
|
||||||
break;
|
break;
|
||||||
System.err.println("Received("+loop+"): "+i);
|
System.err.println("Received("+loop+"): "+i);
|
||||||
|
@ -190,11 +164,8 @@ public class JmsDurableTopicSlowReceiveTest extends JmsTopicSendReceiveTest {
|
||||||
// assertEquals(((BytesMessage) msg).getText(), "test");
|
// assertEquals(((BytesMessage) msg).getText(), "test");
|
||||||
assertEquals(msg.getJMSType(),"test");
|
assertEquals(msg.getJMSType(),"test");
|
||||||
assertEquals(msg.getStringProperty("test"),"test");
|
assertEquals(msg.getStringProperty("test"),"test");
|
||||||
|
|
||||||
// connection3.stop();
|
// connection3.stop();
|
||||||
connection3.close();
|
connection3.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue