activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From michaelpea...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1569 - Queue - User Enhancement
Date Thu, 21 Dec 2017 15:38:38 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 515560be2 -> 30ae2db2b


ARTEMIS-1569 - Queue - User Enhancement 

Expose User associated with creating Queue on JMX QueueControl (as attribute) 
Allow setting of the user to associate with creating the queue when configured in broker.xml
(before only if created over wire is it possible to set the user)

Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/035936cd
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/035936cd
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/035936cd

Branch: refs/heads/master
Commit: 035936cdb899eda5e1397d77bdcf34b9ad513d2d
Parents: 515560b
Author: Michael André Pearce <michael.andre.pearce@me.com>
Authored: Wed Dec 20 23:45:54 2017 +0000
Committer: Michael Pearce <michael.andre.pearce@me.com>
Committed: Thu Dec 21 15:38:17 2017 +0000

----------------------------------------------------------------------
 .../api/core/management/QueueControl.java       |  6 ++++++
 .../core/config/CoreQueueConfiguration.java     | 14 +++++++++++++
 .../deployers/impl/FileConfigurationParser.java |  5 ++++-
 .../core/management/impl/QueueControlImpl.java  | 14 +++++++++++++
 .../core/server/impl/ActiveMQServerImpl.java    |  2 +-
 .../resources/schema/artemis-configuration.xsd  |  8 +++++++
 .../test/resources/artemis-configuration.xsd    |  8 +++++++
 .../management/QueueControlUsingCoreTest.java   |  5 +++++
 .../persistence/QueueConfigRestartTest.java     | 22 ++++++++++++++++++++
 9 files changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
index 2ef8743..d678977 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/QueueControl.java
@@ -57,6 +57,12 @@ public interface QueueControl {
    boolean isDurable();
 
    /**
+    * Returns the user that is associated with creating the queue.
+    */
+   @Attribute(desc = "the user that created the queue")
+   String getUser();
+
+   /**
     * The routing type of this queue.
     */
    @Attribute(desc = "routing type of this queue")

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
index 5108125..6648b7e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java
@@ -33,6 +33,8 @@ public class CoreQueueConfiguration implements Serializable {
 
    private boolean durable = true;
 
+   private String user = null;
+
    private Integer maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
 
    private Boolean purgeOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
@@ -58,6 +60,10 @@ public class CoreQueueConfiguration implements Serializable {
       return durable;
    }
 
+   public String getUser() {
+      return user;
+   }
+
    /**
     * @param address the address to set
     */
@@ -106,6 +112,14 @@ public class CoreQueueConfiguration implements Serializable {
       return this;
    }
 
+   /**
+    * @param user the use you want to associate with creating the queue
+    */
+   public CoreQueueConfiguration setUser(String user) {
+      this.user = user;
+      return this;
+   }
+
    public boolean getPurgeOnNoConsumers() {
       return purgeOnNoConsumers;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index 7f71c86..b29e1b4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -1076,6 +1076,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
       boolean durable = true;
       int maxConsumers = ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
       boolean purgeOnNoConsumers = ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
+      String user = null;
 
       NamedNodeMap attributes = node.getAttributes();
       for (int i = 0; i < attributes.getLength(); i++) {
@@ -1098,10 +1099,12 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
             filterString = getAttributeValue(child, "string");
          } else if (child.getNodeName().equals("durable")) {
             durable = XMLUtil.parseBoolean(child);
+         } else if (child.getNodeName().equals("user")) {
+            user = getTrimmedTextContent(child);
          }
       }
 
-      return new CoreQueueConfiguration().setAddress(address).setName(name).setFilterString(filterString).setDurable(durable).setMaxConsumers(maxConsumers).setPurgeOnNoConsumers(purgeOnNoConsumers);
+      return new CoreQueueConfiguration().setAddress(address).setName(name).setFilterString(filterString).setDurable(durable).setMaxConsumers(maxConsumers).setPurgeOnNoConsumers(purgeOnNoConsumers).setUser(user);
    }
 
    protected CoreAddressConfiguration parseAddressConfiguration(final Node node) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
index 52988d2..6f75297 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java
@@ -176,6 +176,20 @@ public class QueueControlImpl extends AbstractControl implements QueueControl
{
    }
 
    @Override
+   public String getUser() {
+      checkStarted();
+
+      clearIO();
+      try {
+         SimpleString user = queue.getUser();
+         return user == null ? null : user.toString();
+      } finally {
+         blockOnIO();
+      }
+   }
+
+
+   @Override
    public String getRoutingType() {
       checkStarted();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 469828a..a89a43b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -2508,7 +2508,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
             // if the address::queue doesn't exist then create it
             try {
                createQueue(SimpleString.toSimpleString(config.getAddress()), config.getRoutingType(),
-                           queueName, SimpleString.toSimpleString(config.getFilterString()),null,
+                           queueName, SimpleString.toSimpleString(config.getFilterString()),
SimpleString.toSimpleString(config.getUser()),
                            config.isDurable(),false,false,false,false,config.getMaxConsumers(),config.getPurgeOnNoConsumers(),true);
             } catch (ActiveMQQueueExistsException e) {
                // the queue may exist on a *different* address

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 4360b02..18ad6e4 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -477,6 +477,13 @@
                                  </xsd:documentation>
                               </xsd:annotation>
                            </xsd:element>
+                           <xsd:element name="user" type="xsd:string" maxOccurs="1" minOccurs="0">
+                              <xsd:annotation>
+                                 <xsd:documentation>
+                                    user to associate for creating the queue
+                                 </xsd:documentation>
+                              </xsd:annotation>
+                           </xsd:element>
                            <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
                            <xsd:element name="durable" type="xsd:boolean" default="true"
maxOccurs="1" minOccurs="0">
                               <xsd:annotation>
@@ -2987,6 +2994,7 @@
       <xsd:all>
          <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
          <xsd:element name="durable" type="xsd:boolean" default="true" maxOccurs="1" minOccurs="0"
/>
+         <xsd:element name="user" type="xsd:string" maxOccurs="1" minOccurs="0" />
       </xsd:all>
       <xsd:attribute name="name" type="xsd:string" use="required"/>
       <xsd:attribute name="max-consumers" type="xsd:integer" use="optional"/>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/artemis-tools/src/test/resources/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-tools/src/test/resources/artemis-configuration.xsd b/artemis-tools/src/test/resources/artemis-configuration.xsd
index 721c8cb..47a92ff 100644
--- a/artemis-tools/src/test/resources/artemis-configuration.xsd
+++ b/artemis-tools/src/test/resources/artemis-configuration.xsd
@@ -459,6 +459,13 @@
                                  </xsd:documentation>
                               </xsd:annotation>
                            </xsd:element>
+                           <xsd:element name="user" type="xsd:string" maxOccurs="1" minOccurs="0">
+                              <xsd:annotation>
+                                 <xsd:documentation>
+                                    user to associate for creating the queue
+                                 </xsd:documentation>
+                              </xsd:annotation>
+                           </xsd:element>
                            <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
                            <xsd:element name="durable" type="xsd:boolean" default="true"
maxOccurs="1" minOccurs="0">
                               <xsd:annotation>
@@ -2678,6 +2685,7 @@
       <xsd:all>
          <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
          <xsd:element name="durable" type="xsd:boolean" default="true" maxOccurs="1" minOccurs="0"
/>
+         <xsd:element name="user" type="xsd:string" maxOccurs="1" minOccurs="0" />
       </xsd:all>
       <xsd:attribute name="name" type="xsd:string" use="required"/>
       <xsd:attribute name="max-consumers" type="xsd:integer" use="optional"/>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
index dcf5d54..3ea65cc 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlUsingCoreTest.java
@@ -72,6 +72,11 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
          }
 
          @Override
+         public String getUser() {
+            return (String) proxy.retrieveAttributeValue("user");
+         }
+
+         @Override
          public int getConsumerCount() {
             return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/035936cd/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/QueueConfigRestartTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/QueueConfigRestartTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/QueueConfigRestartTest.java
index 0ebb30f..a5973c7 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/QueueConfigRestartTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/persistence/QueueConfigRestartTest.java
@@ -60,6 +60,28 @@ public class QueueConfigRestartTest extends ActiveMQTestBase {
       QueueBinding queueBinding2 = (QueueBinding)server.getPostOffice().getBinding(queue);
       Assert.assertTrue(queueBinding2.getQueue().isPurgeOnNoConsumers());
    }
+
+   @Test
+   public void testQueueConfigUserAndRestart() throws Exception {
+      ActiveMQServer server = createServer(true);
+
+      server.start();
+
+      SimpleString address = new SimpleString("test.address");
+      SimpleString queue = new SimpleString("test.queue");
+
+      server.createQueue(address, RoutingType.MULTICAST, queue, null, SimpleString.toSimpleString("bob"),
true, false, false, 10, true, true);
+
+      QueueBinding queueBinding1 = (QueueBinding)server.getPostOffice().getBinding(queue);
+      Assert.assertEquals(SimpleString.toSimpleString("bob"), queueBinding1.getQueue().getUser());
+
+      server.stop();
+
+      server.start();
+
+      QueueBinding queueBinding2 = (QueueBinding)server.getPostOffice().getBinding(queue);
+      Assert.assertTrue(queueBinding2.getQueue().isPurgeOnNoConsumers());
+   }
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------


Mime
View raw message