mirror of https://github.com/apache/activemq.git
Add try/catch blocks to prevent client shutdown errors from preventing
Broker shutdown.
This commit is contained in:
parent
999385ea53
commit
4a2af3ab07
|
@ -61,8 +61,8 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
|||
protected BrokerService broker;
|
||||
|
||||
// for message listener test
|
||||
private List<Message> unackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||
private List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||
private final List<Message> unackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||
private final List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||
private boolean resendPhase;
|
||||
|
||||
public JmsTransactionTestSupport() {
|
||||
|
@ -78,6 +78,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
|||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
broker = createBroker();
|
||||
broker.start();
|
||||
|
@ -122,16 +123,26 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
|||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
LOG.info("Closing down connection");
|
||||
|
||||
session.close();
|
||||
session = null;
|
||||
connection.close();
|
||||
connection = null;
|
||||
broker.stop();
|
||||
broker.waitUntilStopped();
|
||||
broker = null;
|
||||
try {
|
||||
session.close();
|
||||
session = null;
|
||||
connection.close();
|
||||
connection = null;
|
||||
} catch (Exception e) {
|
||||
LOG.info("Caught exception while closing resources.");
|
||||
}
|
||||
|
||||
try {
|
||||
broker.stop();
|
||||
broker.waitUntilStopped();
|
||||
broker = null;
|
||||
} catch (Exception e) {
|
||||
LOG.info("Caught exception while shutting down the Broker", e);
|
||||
}
|
||||
|
||||
LOG.info("Connection closed.");
|
||||
}
|
||||
|
@ -671,6 +682,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
|||
reconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
if (!resendPhase) {
|
||||
unackMessages.add(message);
|
||||
|
|
Loading…
Reference in New Issue