mirror of https://github.com/apache/activemq.git
Fixing a race between the session being closed and the call to commit in the async handler that caused some exceptions occasionally in the test run.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1003908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
227ed96df0
commit
5f490541f4
|
@ -104,7 +104,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
latch.await(5, TimeUnit.SECONDS);
|
latch.await(5, TimeUnit.SECONDS);
|
||||||
assertEquals(latch.getCount(), 0);
|
assertEquals(latch.getCount(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTransactedSchedule() throws Exception {
|
public void testTransactedSchedule() throws Exception {
|
||||||
final int COUNT = 1;
|
final int COUNT = 1;
|
||||||
Connection connection = createConnection();
|
Connection connection = createConnection();
|
||||||
|
@ -116,12 +116,12 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
final CountDownLatch latch = new CountDownLatch(COUNT);
|
final CountDownLatch latch = new CountDownLatch(COUNT);
|
||||||
consumer.setMessageListener(new MessageListener() {
|
consumer.setMessageListener(new MessageListener() {
|
||||||
public void onMessage(Message message) {
|
public void onMessage(Message message) {
|
||||||
latch.countDown();
|
|
||||||
try {
|
try {
|
||||||
session.commit();
|
session.commit();
|
||||||
} catch (JMSException e) {
|
} catch (JMSException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
assertEquals(NUMBER, count.get());
|
assertEquals(NUMBER, count.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScheduleRestart() throws Exception {
|
public void testScheduleRestart() throws Exception {
|
||||||
// send a message
|
// send a message
|
||||||
Connection connection = createConnection();
|
Connection connection = createConnection();
|
||||||
|
@ -188,16 +188,16 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
|
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
|
||||||
producer.send(message);
|
producer.send(message);
|
||||||
producer.close();
|
producer.close();
|
||||||
|
|
||||||
//restart broker
|
//restart broker
|
||||||
broker.stop();
|
broker.stop();
|
||||||
broker.waitUntilStopped();
|
broker.waitUntilStopped();
|
||||||
|
|
||||||
broker = createBroker(false);
|
broker = createBroker(false);
|
||||||
broker.start();
|
broker.start();
|
||||||
broker.waitUntilStarted();
|
broker.waitUntilStarted();
|
||||||
|
|
||||||
|
|
||||||
// consume the message
|
// consume the message
|
||||||
connection = createConnection();
|
connection = createConnection();
|
||||||
connection.start();
|
connection.start();
|
||||||
|
@ -217,7 +217,7 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
|
||||||
protected BrokerService createBroker() throws Exception {
|
protected BrokerService createBroker() throws Exception {
|
||||||
return createBroker(true);
|
return createBroker(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BrokerService createBroker(boolean delete) throws Exception {
|
protected BrokerService createBroker(boolean delete) throws Exception {
|
||||||
File schedulerDirectory = new File("target/scheduler");
|
File schedulerDirectory = new File("target/scheduler");
|
||||||
if (delete) {
|
if (delete) {
|
||||||
|
|
Loading…
Reference in New Issue