activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r995016 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java
Date Wed, 08 Sep 2010 12:19:44 GMT
Author: dejanb
Date: Wed Sep  8 12:19:43 2010
New Revision: 995016

URL: http://svn.apache.org/viewvc?rev=995016&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2897 - start job scheduler on start

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java?rev=995016&r1=995015&r2=995016&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/scheduler/SchedulerBroker.java
Wed Sep  8 12:19:43 2010
@@ -82,6 +82,7 @@ public class SchedulerBroker extends Bro
     @Override
     public void start() throws Exception {
         this.started.set(true);
+        getInternalScheduler();
         super.start();
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java?rev=995016&r1=995015&r2=995016&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/scheduler/JmsSchedulerTest.java
Wed Sep  8 12:19:43 2010
@@ -176,6 +176,36 @@ public class JmsSchedulerTest extends Em
         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 Em
 
     @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);



Mime
View raw message