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 2ef87432a7..d678977032 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
@@ -56,6 +56,12 @@ public interface QueueControl {
@Attribute(desc = "whether this queue is durable")
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.
*/
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 5108125bea..6648b7ed88 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;
}
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 7f71c86c37..b29e1b4529 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) {
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 52988d2b94..6f75297499 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
@@ -175,6 +175,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();
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 469828ab6e..a89a43bb6f 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
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 4360b027ea..18ad6e4711 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 @@
+
+
+
+ user to associate for creating the queue
+
+
+
@@ -2987,6 +2994,7 @@
+
diff --git a/artemis-tools/src/test/resources/artemis-configuration.xsd b/artemis-tools/src/test/resources/artemis-configuration.xsd
index 721c8cb2a2..47a92ffcb4 100644
--- a/artemis-tools/src/test/resources/artemis-configuration.xsd
+++ b/artemis-tools/src/test/resources/artemis-configuration.xsd
@@ -459,6 +459,13 @@
+
+
+
+ user to associate for creating the queue
+
+
+
@@ -2678,6 +2685,7 @@
+
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 dcf5d54ec2..3ea65ccc5b 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
@@ -71,6 +71,11 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
return (String) proxy.retrieveAttributeValue("address");
}
+ @Override
+ public String getUser() {
+ return (String) proxy.retrieveAttributeValue("user");
+ }
+
@Override
public int getConsumerCount() {
return (Integer) proxy.retrieveAttributeValue("consumerCount", Integer.class);
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 0ebb30f38b..a5973c7e34 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 -----------------------------------------------------