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 @Override
public void start() throws Exception { public void start() throws Exception {
this.started.set(true); this.started.set(true);
getInternalScheduler();
super.start(); super.start();
} }

View File

@ -177,6 +177,36 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
assertEquals(NUMBER, count.get()); 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 @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
bindAddress = "vm://localhost"; bindAddress = "vm://localhost";
@ -185,9 +215,15 @@ public class JmsSchedulerTest extends EmbeddedBrokerTestSupport {
@Override @Override
protected BrokerService createBroker() throws Exception { protected BrokerService createBroker() throws Exception {
return createBroker(true);
}
protected BrokerService createBroker(boolean delete) throws Exception {
File schedulerDirectory = new File("target/scheduler"); File schedulerDirectory = new File("target/scheduler");
if (delete) {
IOHelper.mkdirs(schedulerDirectory); IOHelper.mkdirs(schedulerDirectory);
IOHelper.deleteChildren(schedulerDirectory); IOHelper.deleteChildren(schedulerDirectory);
}
BrokerService answer = new BrokerService(); BrokerService answer = new BrokerService();
answer.setPersistent(isPersistent()); answer.setPersistent(isPersistent());
answer.setDeleteAllMessagesOnStartup(true); answer.setDeleteAllMessagesOnStartup(true);