You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2011/10/07 12:57:41 UTC

svn commit: r1179999 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/jdbc/Statements.java test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java

Author: gtully
Date: Fri Oct  7 10:57:41 2011
New Revision: 1179999

URL: http://svn.apache.org/viewvc?rev=1179999&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3526 - JDBC persistence adapter, destination mbeans not visible on restart till producers or consumers reattach. query to find inactive destinations was checking the wrong table name, resolved with new test

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java   (with props)
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java?rev=1179999&r1=1179998&r2=1179999&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java Fri Oct  7 10:57:41 2011
@@ -356,7 +356,7 @@ public class Statements {
 
     public String getFindAllDestinationsStatement() {
         if (findAllDestinationsStatement == null) {
-            findAllDestinationsStatement = "SELECT DISTINCT CONTAINER FROM " + getFullAckTableName();
+            findAllDestinationsStatement = "SELECT DISTINCT CONTAINER FROM " + getFullMessageTableName();
         }
         return findAllDestinationsStatement;
     }

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java?rev=1179999&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java Fri Oct  7 10:57:41 2011
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.broker;
+
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.management.ObjectName;
+import junit.framework.Test;
+import org.apache.activemq.TestSupport;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.util.JMXSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class QueueMbeanRestartTest extends TestSupport {
+    private static final transient Logger LOG = LoggerFactory.getLogger(QueueMbeanRestartTest.class);
+
+    BrokerService broker;
+
+    public static Test suite() {
+        return suite(QueueMbeanRestartTest.class);
+    }
+
+    public void setUp() throws Exception {
+        topic = false;
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception {
+        super.tearDown();
+        broker.stop();
+    }
+
+    public void initCombosForTestMBeanPresenceOnRestart() {
+        addCombinationValues("defaultPersistenceAdapter",
+                new Object[]{PersistenceAdapterChoice.KahaDB, PersistenceAdapterChoice.JDBC});
+    }
+
+    public void testMBeanPresenceOnRestart() throws Exception {
+        createBroker(true);
+
+        sendMessages();
+        verifyPresenceOfQueueMbean();
+        LOG.info("restart....");
+
+        restartBroker();
+        verifyPresenceOfQueueMbean();
+    }
+
+    private void restartBroker() throws Exception {
+        broker.stop();
+        broker.waitUntilStopped();
+        createBroker(false);
+    }
+
+    private void verifyPresenceOfQueueMbean() throws Exception {
+        for (ObjectName name : broker.getManagementContext().queryNames(null, null)) {
+            LOG.info("candidate :" + name);
+            String type = name.getKeyProperty("Type");
+            if (type != null && type.equals("Queue")) {
+                assertEquals(
+                        JMXSupport.encodeObjectNamePart(((ActiveMQQueue) createDestination()).getPhysicalName()),
+                        name.getKeyProperty("Destination"));
+                LOG.info("found mbbean " + name);
+                return;
+            }
+        }
+        fail("expected to find matching queue mbean for: " + createDestination());
+    }
+
+    private void sendMessages() throws Exception {
+        Session session = createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(createDestination());
+        producer.send(session.createTextMessage());
+    }
+
+    private void createBroker(boolean deleteAll) throws Exception {
+        broker = new BrokerService();
+        setDefaultPersistenceAdapter(broker);
+
+        broker.setDeleteAllMessagesOnStartup(deleteAll);
+        broker.start();
+    }
+}
\ No newline at end of file

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/QueueMbeanRestartTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date