git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@995016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-09-08 12:19:43 +00:00
parent 0585bc10cd
commit e8a4a32c83
2 changed files with 39 additions and 2 deletions

View File

@ -82,6 +82,7 @@ public class SchedulerBroker extends BrokerFilter implements JobListener {
@Override
public void start() throws Exception {
this.started.set(true);
getInternalScheduler();
super.start();
}

View File

@ -176,6 +176,36 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
Thread.sleep(1000);
assertEquals(NUMBER, count.get());
}
public void testScheduleRestart() throws Exception {
// send a message
Connection connection = createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage("test msg");
long time = 5000;
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, time);
producer.send(message);
producer.close();
//restart broker
broker.stop();
broker.waitUntilStopped();
broker = createBroker(false);
broker.start();
broker.waitUntilStarted();
// consume the message
connection = createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination);
Message msg = consumer.receive(5000);
assertNotNull("Didn't receive the message", msg);
}
@Override
protected void setUp() throws Exception {
@ -185,9 +215,15 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
@Override
protected BrokerService createBroker() throws Exception {
return createBroker(true);
}
protected BrokerService createBroker(boolean delete) throws Exception {
File schedulerDirectory = new File("target/scheduler");
IOHelper.mkdirs(schedulerDirectory);
IOHelper.deleteChildren(schedulerDirectory);
if (delete) {
IOHelper.mkdirs(schedulerDirectory);
IOHelper.deleteChildren(schedulerDirectory);
}
BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent());
answer.setDeleteAllMessagesOnStartup(true);