mirror of https://github.com/apache/activemq.git
On my old dual core Macbook this test sometimes fails because the listener has a four second wait and the test only allocates five seconds for processing of the messages to complete after the producer transaction commit is called.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1437739 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2dd8b61a4b
commit
6d2f262ceb
|
@ -70,7 +70,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
long done = System.currentTimeMillis() + getMaxTestTime();
|
long done = System.currentTimeMillis() + getMaxTestTime();
|
||||||
synchronized (testMutex) {
|
synchronized (testMutex) {
|
||||||
while (!testMutex.testCompleted && System.currentTimeMillis() < done) {
|
while (!testMutex.testCompleted && System.currentTimeMillis() < done) {
|
||||||
testMutex.wait(TimeUnit.SECONDS.toMillis(5));
|
testMutex.wait(TimeUnit.SECONDS.toMillis(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
|
return new ActiveMQConnectionFactory(broker.getTransportConnectors().get(0).getPublishableConnectString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
setAutoFail(true);
|
setAutoFail(true);
|
||||||
bindAddress = "tcp://localhost:0";
|
bindAddress = "tcp://localhost:0";
|
||||||
|
@ -98,12 +99,14 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
connection.start();
|
connection.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
connectionConsumer.close();
|
connectionConsumer.close();
|
||||||
connection.close();
|
connection.close();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected BrokerService createBroker() throws Exception {
|
protected BrokerService createBroker() throws Exception {
|
||||||
BrokerService answer = super.createBroker();
|
BrokerService answer = super.createBroker();
|
||||||
PolicyMap policyMap = new PolicyMap();
|
PolicyMap policyMap = new PolicyMap();
|
||||||
|
@ -130,6 +133,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
serverSession = new TestServerSession(this);
|
serverSession = new TestServerSession(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ServerSession getServerSession() throws JMSException {
|
public ServerSession getServerSession() throws JMSException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (serverSessionInUse) {
|
if (serverSessionInUse) {
|
||||||
|
@ -155,13 +159,16 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
session.setMessageListener(new TestMessageListener());
|
session.setMessageListener(new TestMessageListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Session getSession() throws JMSException {
|
public Session getSession() throws JMSException {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void start() throws JMSException {
|
public void start() throws JMSException {
|
||||||
// use a separate thread to process the message asynchronously
|
// use a separate thread to process the message asynchronously
|
||||||
new Thread() {
|
new Thread() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// let the session deliver the message
|
// let the session deliver the message
|
||||||
session.run();
|
session.run();
|
||||||
|
@ -187,6 +194,7 @@ public class OnePrefetchAsyncConsumerTest extends EmbeddedBrokerTestSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestMessageListener implements MessageListener {
|
private class TestMessageListener implements MessageListener {
|
||||||
|
@Override
|
||||||
public void onMessage(Message message) {
|
public void onMessage(Message message) {
|
||||||
try {
|
try {
|
||||||
String text = ((TextMessage)message).getText();
|
String text = ((TextMessage)message).getText();
|
||||||
|
|
Loading…
Reference in New Issue