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;
|
protected BrokerService broker;
|
||||||
|
|
||||||
// for message listener test
|
// for message listener test
|
||||||
private List<Message> unackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
private final List<Message> unackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||||
private List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
private final List<Message> ackMessages = new ArrayList<Message>(MESSAGE_COUNT);
|
||||||
private boolean resendPhase;
|
private boolean resendPhase;
|
||||||
|
|
||||||
public JmsTransactionTestSupport() {
|
public JmsTransactionTestSupport() {
|
||||||
|
@ -78,6 +78,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
||||||
*
|
*
|
||||||
* @see junit.framework.TestCase#setUp()
|
* @see junit.framework.TestCase#setUp()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
broker = createBroker();
|
broker = createBroker();
|
||||||
broker.start();
|
broker.start();
|
||||||
|
@ -122,16 +123,26 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
||||||
*
|
*
|
||||||
* @see junit.framework.TestCase#tearDown()
|
* @see junit.framework.TestCase#tearDown()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
LOG.info("Closing down connection");
|
LOG.info("Closing down connection");
|
||||||
|
|
||||||
|
try {
|
||||||
session.close();
|
session.close();
|
||||||
session = null;
|
session = null;
|
||||||
connection.close();
|
connection.close();
|
||||||
connection = null;
|
connection = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.info("Caught exception while closing resources.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
broker.stop();
|
broker.stop();
|
||||||
broker.waitUntilStopped();
|
broker.waitUntilStopped();
|
||||||
broker = null;
|
broker = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.info("Caught exception while shutting down the Broker", e);
|
||||||
|
}
|
||||||
|
|
||||||
LOG.info("Connection closed.");
|
LOG.info("Connection closed.");
|
||||||
}
|
}
|
||||||
|
@ -671,6 +682,7 @@ public abstract class JmsTransactionTestSupport extends TestSupport implements M
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onMessage(Message message) {
|
public void onMessage(Message message) {
|
||||||
if (!resendPhase) {
|
if (!resendPhase) {
|
||||||
unackMessages.add(message);
|
unackMessages.add(message);
|
||||||
|
|
Loading…
Reference in New Issue