mirror of
https://github.com/apache/activemq.git
synced 2025-02-17 15:35:36 +00:00
making ExpiredMessagesTest pass on very slow machines
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@902816 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d2791aee90
commit
57b8927743
@ -16,6 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.activemq.usecases;
|
package org.apache.activemq.usecases;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
|
import javax.jms.DeliveryMode;
|
||||||
|
import javax.jms.Message;
|
||||||
|
import javax.jms.MessageConsumer;
|
||||||
|
import javax.jms.MessageListener;
|
||||||
|
import javax.jms.MessageProducer;
|
||||||
|
import javax.jms.Session;
|
||||||
|
import javax.management.InstanceNotFoundException;
|
||||||
|
import javax.management.ObjectName;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.CombinationTestSupport;
|
import org.apache.activemq.CombinationTestSupport;
|
||||||
import org.apache.activemq.broker.BrokerService;
|
import org.apache.activemq.broker.BrokerService;
|
||||||
@ -29,17 +44,6 @@ import org.apache.activemq.store.amq.AMQPersistenceAdapter;
|
|||||||
import org.apache.activemq.util.Wait;
|
import org.apache.activemq.util.Wait;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import java.io.File;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import javax.jms.Connection;
|
|
||||||
import javax.jms.DeliveryMode;
|
|
||||||
import javax.jms.Message;
|
|
||||||
import javax.jms.MessageConsumer;
|
|
||||||
import javax.jms.MessageProducer;
|
|
||||||
import javax.jms.Session;
|
|
||||||
import javax.management.InstanceNotFoundException;
|
|
||||||
import javax.management.ObjectName;
|
|
||||||
import junit.framework.Test;
|
|
||||||
|
|
||||||
public class ExpiredMessagesTest extends CombinationTestSupport {
|
public class ExpiredMessagesTest extends CombinationTestSupport {
|
||||||
|
|
||||||
@ -177,16 +181,30 @@ public class ExpiredMessagesTest extends CombinationTestSupport {
|
|||||||
assertEquals("memory usage is back to duck egg", 0, view.getMemoryPercentUsage());
|
assertEquals("memory usage is back to duck egg", 0, view.getMemoryPercentUsage());
|
||||||
assertTrue("memory usage is increased ", 0 < dlqView.getMemoryPercentUsage());
|
assertTrue("memory usage is increased ", 0 < dlqView.getMemoryPercentUsage());
|
||||||
|
|
||||||
// verify DQL
|
// verify DLQ
|
||||||
MessageConsumer dlqConsumer = createDlqConsumer(connection);
|
MessageConsumer dlqConsumer = createDlqConsumer(connection);
|
||||||
int count = 0;
|
final DLQListener dlqListener = new DLQListener();
|
||||||
while (dlqConsumer.receive(4000) != null) {
|
dlqConsumer.setMessageListener(dlqListener);
|
||||||
count++;
|
|
||||||
}
|
Wait.waitFor(new Wait.Condition() {
|
||||||
assertEquals("dlq returned all expired", count, totalExpiredCount);
|
public boolean isSatisified() throws Exception {
|
||||||
|
return totalExpiredCount == dlqListener.count;
|
||||||
|
}
|
||||||
|
}, 60 * 1000);
|
||||||
|
|
||||||
|
assertEquals("dlq returned all expired", dlqListener.count, totalExpiredCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DLQListener implements MessageListener {
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
public void onMessage(Message message) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
private MessageConsumer createDlqConsumer(Connection connection) throws Exception {
|
private MessageConsumer createDlqConsumer(Connection connection) throws Exception {
|
||||||
return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(dlqDestination);
|
return connection.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(dlqDestination);
|
||||||
}
|
}
|
||||||
@ -272,7 +290,7 @@ public class ExpiredMessagesTest extends CombinationTestSupport {
|
|||||||
BrokerService broker = new BrokerService();
|
BrokerService broker = new BrokerService();
|
||||||
broker.setBrokerName("localhost");
|
broker.setBrokerName("localhost");
|
||||||
AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
|
AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
|
||||||
adaptor.setDirectory(new File("data/"));
|
adaptor.setDirectory(new File("target/expiredtest-data/"));
|
||||||
adaptor.setForceRecoverReferenceStore(true);
|
adaptor.setForceRecoverReferenceStore(true);
|
||||||
broker.setPersistenceAdapter(adaptor);
|
broker.setPersistenceAdapter(adaptor);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user