mirror of https://github.com/apache/activemq.git
NO-JIRA update the AMQP tests to use the client close timeout
Use the client built in close timeout instead of the executor which can
leave threads running and causes the tests to take much longer than
needed.
(cherry picked from commit ce551cf97d
)
This commit is contained in:
parent
6613b8f1f6
commit
3b5a4d7078
|
@ -25,8 +25,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
||||||
|
@ -69,8 +67,6 @@ public class AmqpTestSupport {
|
||||||
|
|
||||||
protected static final Logger LOG = LoggerFactory.getLogger(AmqpTestSupport.class);
|
protected static final Logger LOG = LoggerFactory.getLogger(AmqpTestSupport.class);
|
||||||
|
|
||||||
protected ExecutorService testService = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
protected BrokerService brokerService;
|
protected BrokerService brokerService;
|
||||||
protected Vector<Throwable> exceptions = new Vector<>();
|
protected Vector<Throwable> exceptions = new Vector<>();
|
||||||
protected int numberOfMessages;
|
protected int numberOfMessages;
|
||||||
|
|
|
@ -215,6 +215,7 @@ public class JMSClientContext {
|
||||||
factory.setForceSyncSend(syncPublish);
|
factory.setForceSyncSend(syncPublish);
|
||||||
factory.setTopicPrefix("topic://");
|
factory.setTopicPrefix("topic://");
|
||||||
factory.setQueuePrefix("queue://");
|
factory.setQueuePrefix("queue://");
|
||||||
|
factory.setCloseTimeout(60000);
|
||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,6 @@ package org.apache.activemq.transport.amqp;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
import javax.jms.JMSException;
|
import javax.jms.JMSException;
|
||||||
|
@ -33,40 +28,18 @@ public class JMSClientTestSupport extends AmqpTestSupport {
|
||||||
|
|
||||||
protected Connection connection;
|
protected Connection connection;
|
||||||
|
|
||||||
private Thread connectionCloseThread;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
Future<Boolean> future = testService.submit(new CloseConnectionTask());
|
|
||||||
try {
|
try {
|
||||||
LOG.debug("tearDown started.");
|
LOG.debug("tearDown started.");
|
||||||
future.get(60, TimeUnit.SECONDS);
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
if (connectionCloseThread != null) {
|
|
||||||
connectionCloseThread.interrupt();;
|
|
||||||
}
|
|
||||||
|
|
||||||
testService.shutdownNow();
|
|
||||||
testService = Executors.newSingleThreadExecutor();
|
|
||||||
throw new Exception("CloseConnection timed out");
|
|
||||||
} finally {
|
|
||||||
connectionCloseThread = null;
|
|
||||||
connection = null;
|
|
||||||
super.tearDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CloseConnectionTask implements Callable<Boolean> {
|
|
||||||
@Override
|
|
||||||
public Boolean call() throws Exception {
|
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
connectionCloseThread = Thread.currentThread();
|
|
||||||
LOG.debug("in CloseConnectionTask.call(), calling connection.close()");
|
LOG.debug("in CloseConnectionTask.call(), calling connection.close()");
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
return Boolean.TRUE;
|
connection = null;
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue