You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/12/09 19:49:06 UTC

[22/50] [abbrv] activemq-artemis git commit: ARTEMIS-878 Update the CLI to incorporate Addresses and new Queue

ARTEMIS-878 Update the CLI to incorporate Addresses and new Queue


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

Branch: refs/heads/master
Commit: ec8f06138c3f93c568934a859044125321a2fa47
Parents: a88853f
Author: Martyn Taylor <mt...@redhat.com>
Authored: Fri Nov 11 14:08:49 2016 +0000
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Fri Dec 9 18:43:15 2016 +0000

----------------------------------------------------------------------
 .../apache/activemq/artemis/cli/Artemis.java    |  15 +-
 .../artemis/cli/commands/AbstractAction.java    |  62 +++++
 .../cli/commands/address/CreateAddress.java     | 101 ++++++++
 .../cli/commands/address/DeleteAddress.java     |  67 ++++++
 .../cli/commands/address/HelpAddress.java       |  56 +++++
 .../cli/commands/address/ShowAddress.java       |  84 +++++++
 .../commands/destination/CreateDestination.java | 147 ------------
 .../commands/destination/DeleteDestination.java | 121 ----------
 .../commands/destination/DestinationAction.java | 128 -----------
 .../commands/destination/HelpDestination.java   |  56 -----
 .../artemis/cli/commands/queue/CreateQueue.java | 117 ++++++++++
 .../artemis/cli/commands/queue/DeleteQueue.java |  85 +++++++
 .../artemis/cli/commands/queue/HelpQueue.java   |  56 +++++
 .../apache/activemq/cli/test/ArtemisTest.java   |   5 +-
 .../ActiveMQAddressDoesNotExistException.java   |  31 +++
 .../core/ActiveMQDeleteAddressException.java    |  31 +++
 .../artemis/api/core/ActiveMQException.java     |   1 -
 .../artemis/api/core/ActiveMQExceptionType.java |  12 +
 .../core/management/ActiveMQServerControl.java  |  42 ++++
 .../impl/ActiveMQServerControlImpl.java         |  72 +++++-
 .../artemis/core/postoffice/PostOffice.java     |   3 +
 .../core/postoffice/impl/PostOfficeImpl.java    |  59 +++--
 .../core/server/ActiveMQMessageBundle.java      |  12 +
 .../artemis/core/server/ActiveMQServer.java     |  24 +-
 .../core/server/ActiveMQServerLogger.java       |   2 +-
 .../core/server/impl/ActiveMQServerImpl.java    | 117 +++++-----
 .../artemis/core/server/impl/AddressInfo.java   |   4 +-
 .../artemis/core/server/impl/QueueImpl.java     |   9 +-
 .../core/server/impl/ServerSessionImpl.java     |   2 +-
 .../management/impl/ManagementServiceImpl.java  |   1 -
 .../integration/addressing/AddressingTest.java  |  10 +-
 .../integration/cli/AddressCommandTest.java     | 155 +++++++++++++
 .../integration/cli/DestinationCommandTest.java | 226 ------------------
 .../integration/cli/DummyServerConsumer.java    | 204 +++++++++++++++++
 .../tests/integration/cli/QueueCommandTest.java | 228 +++++++++++++++++++
 .../ActiveMQServerControlUsingCoreTest.java     |  36 +++
 .../integration/mqtt/imported/MQTTTest.java     |   4 +-
 .../core/server/impl/fakes/FakePostOffice.java  |   6 +
 38 files changed, 1614 insertions(+), 777 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index 17c4457..94779fc 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -30,9 +30,11 @@ import org.apache.activemq.artemis.cli.commands.Kill;
 import org.apache.activemq.artemis.cli.commands.Mask;
 import org.apache.activemq.artemis.cli.commands.Run;
 import org.apache.activemq.artemis.cli.commands.Stop;
-import org.apache.activemq.artemis.cli.commands.destination.CreateDestination;
-import org.apache.activemq.artemis.cli.commands.destination.DeleteDestination;
-import org.apache.activemq.artemis.cli.commands.destination.HelpDestination;
+import org.apache.activemq.artemis.cli.commands.address.CreateAddress;
+import org.apache.activemq.artemis.cli.commands.address.DeleteAddress;
+import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
+import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
+import org.apache.activemq.artemis.cli.commands.queue.HelpQueue;
 import org.apache.activemq.artemis.cli.commands.messages.Browse;
 import org.apache.activemq.artemis.cli.commands.messages.Consumer;
 import org.apache.activemq.artemis.cli.commands.messages.Producer;
@@ -128,8 +130,11 @@ public class Artemis {
       String instance = artemisInstance != null ? artemisInstance.getAbsolutePath() : System.getProperty("artemis.instance");
       Cli.CliBuilder<Action> builder = Cli.<Action>builder("artemis").withDescription("ActiveMQ Artemis Command Line").withCommand(HelpAction.class).withCommand(Producer.class).withCommand(Consumer.class).withCommand(Browse.class).withCommand(Mask.class).withDefaultCommand(HelpAction.class);
 
-      builder.withGroup("destination").withDescription("Destination tools group (create|delete) (example ./artemis destination create)").
-         withDefaultCommand(HelpDestination.class).withCommands(CreateDestination.class, DeleteDestination.class);
+      builder.withGroup("queue").withDescription("Queue tools group (create|delete) (example ./artemis queue create)").
+         withDefaultCommand(HelpQueue.class).withCommands(CreateQueue.class, DeleteQueue.class);
+
+      builder.withGroup("address").withDescription("Queue tools group (create|delete) (example ./artemis queue create)").
+         withDefaultCommand(HelpQueue.class).withCommands(CreateAddress.class, DeleteAddress.class);
 
       if (instance != null) {
          builder.withGroup("data").withDescription("data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)").

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AbstractAction.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AbstractAction.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AbstractAction.java
new file mode 100644
index 0000000..b4dbba8
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/AbstractAction.java
@@ -0,0 +1,62 @@
+/*
+ * 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.artemis.cli.commands;
+
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.client.ClientRequestor;
+import org.apache.activemq.artemis.api.core.client.ClientSession;
+import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
+import org.apache.activemq.artemis.api.core.client.ServerLocator;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+
+public abstract class AbstractAction extends ConnectionAbstract {
+
+   public void performCoreManagement(ManagementCallback<ClientMessage> cb) throws Exception {
+
+      try (ActiveMQConnectionFactory factory = createConnectionFactory();
+         ServerLocator locator = factory.getServerLocator();
+           ClientSessionFactory sessionFactory = locator.createSessionFactory();
+           ClientSession session = sessionFactory.createSession(user, password, false, true, true, false, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE)) {
+         session.start();
+         ClientRequestor requestor = new ClientRequestor(session, "activemq.management");
+         ClientMessage message = session.createMessage(false);
+
+         cb.setUpInvocation(message);
+
+         ClientMessage reply = requestor.request(message);
+
+         if (ManagementHelper.hasOperationSucceeded(reply)) {
+            cb.requestSuccessful(reply);
+         } else {
+            cb.requestFailed(reply);
+         }
+      }
+   }
+
+   public interface ManagementCallback<T> {
+
+      void setUpInvocation(T message) throws Exception;
+
+      void requestSuccessful(T reply) throws Exception;
+
+      void requestFailed(T reply) throws Exception;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
new file mode 100644
index 0000000..6c92dc6
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/CreateAddress.java
@@ -0,0 +1,101 @@
+/*
+ * 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.artemis.cli.commands.address;
+
+import io.airlift.airline.Command;
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+
+@Command(name = "create", description = "create an address")
+public class CreateAddress extends AbstractAction {
+
+   @Option(name = "--name", description = "The name of this address")
+   String name;
+
+   @Option(name = "--routingType", description = "The routing type of the address, options are 'anycast' or 'multicast', defaults to 1 = 'multicast'")
+   String routingType = "multicast";
+
+   @Option(name = "--defaultMaxConsumers", description = "Sets the default max consumers for any queues created under this address, default = -1 (no limit)")
+   int defaultMaxConsumers = -1;
+
+   @Option(name = "--defaultDeleteOnNoConsumers", description = "Sets the default delete on no consumers for any queues created under this address, default = false")
+   boolean defaultDeleteOnNoConsumers = false;
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+      createAddress(context);
+      return null;
+   }
+
+   private void createAddress(final ActionContext context) throws Exception {
+      performCoreManagement(new ManagementCallback<ClientMessage>() {
+         @Override
+         public void setUpInvocation(ClientMessage message) throws Exception {
+            ManagementHelper.putOperationInvocation(message, "broker", "createAddress", getName(), routingType, defaultDeleteOnNoConsumers, defaultMaxConsumers);
+         }
+
+         @Override
+         public void requestSuccessful(ClientMessage reply) throws Exception {
+            context.out.println("Address " + getName() + " created successfully.");
+         }
+
+         @Override
+         public void requestFailed(ClientMessage reply) throws Exception {
+            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
+            context.err.println("Failed to create address " + getName() + ". Reason: " + errMsg);
+         }
+      });
+   }
+
+   public void setName(String name) {
+      this.name = name;
+   }
+
+   public String getName() {
+      return name;
+   }
+
+   public String getRoutingType() {
+      return routingType;
+   }
+
+   public void setRoutingType(String routingType) {
+      this.routingType = routingType;
+   }
+
+   public int getDefaultMaxConsumers() {
+      return defaultMaxConsumers;
+   }
+
+   public void setDefaultMaxConsumers(int defaultMaxConsumers) {
+      this.defaultMaxConsumers = defaultMaxConsumers;
+   }
+
+   public boolean getDefaultDeleteOnNoConsumers() {
+      return defaultDeleteOnNoConsumers;
+   }
+
+   public void setDefaultDeleteOnNoConsumers(boolean defaultDeleteOnNoConsumers) {
+      this.defaultDeleteOnNoConsumers = defaultDeleteOnNoConsumers;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/DeleteAddress.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/DeleteAddress.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/DeleteAddress.java
new file mode 100644
index 0000000..36c9224
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/DeleteAddress.java
@@ -0,0 +1,67 @@
+/*
+ * 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.artemis.cli.commands.address;
+
+import io.airlift.airline.Command;
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+
+@Command(name = "delete", description = "delete a queue")
+public class DeleteAddress extends AbstractAction {
+
+   @Option(name = "--name", description = "The name of this address")
+   String name;
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+      deleteAddress(context);
+      return null;
+   }
+
+   private void deleteAddress(final ActionContext context) throws Exception {
+      performCoreManagement(new ManagementCallback<ClientMessage>() {
+         @Override
+         public void setUpInvocation(ClientMessage message) throws Exception {
+            ManagementHelper.putOperationInvocation(message, "broker", "deleteAddress", getName());
+         }
+
+         @Override
+         public void requestSuccessful(ClientMessage reply) throws Exception {
+            context.out.println("Address " + getName() + " deleted successfully.");
+         }
+
+         @Override
+         public void requestFailed(ClientMessage reply) throws Exception {
+            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
+            context.err.println("Failed to delete address " + getName() + ". Reason: " + errMsg);
+         }
+      });
+   }
+
+   public String getName() {
+      return name;
+   }
+
+   public void setName(String name) {
+      this.name = name;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/HelpAddress.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/HelpAddress.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/HelpAddress.java
new file mode 100644
index 0000000..c086c01
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/HelpAddress.java
@@ -0,0 +1,56 @@
+/*
+ * 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.artemis.cli.commands.address;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import io.airlift.airline.Help;
+import org.apache.activemq.artemis.cli.commands.Action;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+
+public class HelpAddress extends Help implements Action {
+
+   @Override
+   public boolean isVerbose() {
+      return false;
+   }
+
+   @Override
+   public void setHomeValues(File brokerHome, File brokerInstance) {
+   }
+
+   @Override
+   public String getBrokerInstance() {
+      return null;
+   }
+
+   @Override
+   public String getBrokerHome() {
+      return null;
+   }
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      List<String> commands = new ArrayList<>(1);
+      commands.add("queue");
+      help(global, commands);
+      return null;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/ShowAddress.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/ShowAddress.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/ShowAddress.java
new file mode 100644
index 0000000..34331bb
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/address/ShowAddress.java
@@ -0,0 +1,84 @@
+/*
+ * 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.artemis.cli.commands.address;
+
+import io.airlift.airline.Command;
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+
+@Command(name = "show", description = "delete a queue")
+public class ShowAddress extends AbstractAction {
+
+   @Option(name = "--name", description = "The name of this address")
+   String name;
+
+   @Option(name = "--bindings", description = "Shows the bindings for this address")
+   boolean bindings;
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+      showAddress(context);
+      return null;
+   }
+
+   private void showAddress(final ActionContext context) throws Exception {
+      performCoreManagement(new ManagementCallback<ClientMessage>() {
+         @Override
+         public void setUpInvocation(ClientMessage message) throws Exception {
+            if (bindings) {
+               ManagementHelper.putOperationInvocation(message, "broker", "listBindingsForAddress", getName());
+            }
+            else {
+               ManagementHelper.putOperationInvocation(message, "broker", "getAddressInfo", getName());
+            }
+         }
+
+         @Override
+         public void requestSuccessful(ClientMessage reply) throws Exception {
+            String result = (String) ManagementHelper.getResult(reply, String.class);
+            context.out.println(result);
+         }
+
+         @Override
+         public void requestFailed(ClientMessage reply) throws Exception {
+            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
+            context.err.println("Failed to show address " + getName() + ". Reason: " + errMsg);
+         }
+      });
+   }
+
+   public String getName() {
+      return name;
+   }
+
+   public void setName(String name) {
+      this.name = name;
+   }
+
+   public boolean isBindings() {
+      return bindings;
+   }
+
+   public void setBindings(boolean bindings) {
+      this.bindings = bindings;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java
deleted file mode 100644
index 4cbaaa6..0000000
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/CreateDestination.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.artemis.cli.commands.destination;
-
-import javax.jms.Message;
-
-import io.airlift.airline.Command;
-import io.airlift.airline.Option;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.management.ManagementHelper;
-import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
-import org.apache.activemq.artemis.cli.commands.ActionContext;
-
-@Command(name = "create", description = "create a queue or topic")
-public class CreateDestination extends DestinationAction {
-
-   @Option(name = "--filter", description = "queue's filter string (default null)")
-   String filter = null;
-
-   @Option(name = "--address", description = "address of the core queue (default queue's name)")
-   String address;
-
-   @Option(name = "--durable", description = "whether the queue is durable or not (default false)")
-   boolean durable = false;
-
-   @Option(name = "--bindings", description = "comma separated jndi binding names (default null)")
-   String bindings = null;
-
-   @Override
-   public Object execute(ActionContext context) throws Exception {
-      super.execute(context);
-
-      if (JMS_QUEUE.equals(destType)) {
-         createJmsQueue(context);
-      } else if (CORE_QUEUE.equals(destType)) {
-         createCoreQueue(context);
-      } else if (JMS_TOPIC.equals(destType)) {
-         createJmsTopic(context);
-      } else {
-         throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE);
-      }
-      return null;
-   }
-
-   private void createJmsTopic(final ActionContext context) throws Exception {
-      performJmsManagement(new ManagementCallback<Message>() {
-         @Override
-         public void setUpInvocation(Message message) throws Exception {
-            JMSManagementHelper.putOperationInvocation(message, "jms.server", "createTopic", getName(), bindings);
-         }
-
-         @Override
-         public void requestSuccessful(Message reply) throws Exception {
-            boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
-            if (result) {
-               context.out.println("Topic " + getName() + " created successfully.");
-            } else {
-               context.err.println("Failed to create topic " + getName() + ".");
-            }
-         }
-
-         @Override
-         public void requestFailed(Message reply) throws Exception {
-            String errorMsg = (String) JMSManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to create topic " + getName() + ". Reason: " + errorMsg);
-         }
-      });
-   }
-
-   public String getAddress() {
-      if (address == null || "".equals(address.trim())) {
-         address = getName();
-      }
-      return address.trim();
-   }
-
-   private void createCoreQueue(final ActionContext context) throws Exception {
-      performCoreManagement(new ManagementCallback<ClientMessage>() {
-         @Override
-         public void setUpInvocation(ClientMessage message) throws Exception {
-            String address = getAddress();
-            ManagementHelper.putOperationInvocation(message, "core.server", "createQueue", address, getName(), filter, durable);
-         }
-
-         @Override
-         public void requestSuccessful(ClientMessage reply) throws Exception {
-            context.out.println("Core queue " + getName() + " created successfully.");
-         }
-
-         @Override
-         public void requestFailed(ClientMessage reply) throws Exception {
-            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to create queue " + getName() + ". Reason: " + errMsg);
-         }
-      });
-   }
-
-   private void createJmsQueue(final ActionContext context) throws Exception {
-
-      performJmsManagement(new ManagementCallback<Message>() {
-
-         @Override
-         public void setUpInvocation(Message message) throws Exception {
-            JMSManagementHelper.putOperationInvocation(message, "jms.server", "createQueue", getName(), bindings, filter, durable);
-         }
-
-         @Override
-         public void requestSuccessful(Message reply) throws Exception {
-            boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
-            if (result) {
-               context.out.println("Jms queue " + getName() + " created successfully.");
-            } else {
-               context.err.println("Failed to create jms queue " + getName() + ".");
-            }
-         }
-
-         @Override
-         public void requestFailed(Message reply) throws Exception {
-            String errorMsg = (String) JMSManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to create jms queue " + getName() + ". Reason: " + errorMsg);
-         }
-      });
-   }
-
-   public void setFilter(String filter) {
-      this.filter = filter;
-   }
-
-   public void setBindings(String bindings) {
-      this.bindings = bindings;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java
deleted file mode 100644
index 93dbf5e..0000000
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DeleteDestination.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.artemis.cli.commands.destination;
-
-import javax.jms.Message;
-
-import io.airlift.airline.Command;
-import io.airlift.airline.Option;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.management.ManagementHelper;
-import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
-import org.apache.activemq.artemis.cli.commands.ActionContext;
-
-@Command(name = "delete", description = "delete a queue or topic")
-public class DeleteDestination extends DestinationAction {
-
-   @Option(name = "--removeConsumers", description = "whether deleting destination with consumers or not (default false)")
-   boolean removeConsumers = false;
-
-   @Override
-   public Object execute(ActionContext context) throws Exception {
-      super.execute(context);
-
-      if (JMS_QUEUE.equals(destType)) {
-         deleteJmsQueue(context);
-      } else if (CORE_QUEUE.equals(destType)) {
-         deleteCoreQueue(context);
-      } else if (JMS_TOPIC.equals(destType)) {
-         deleteJmsTopic(context);
-      } else {
-         throw new IllegalArgumentException("--type can only be one of " + JMS_QUEUE + ", " + JMS_TOPIC + " and " + CORE_QUEUE);
-      }
-      return null;
-   }
-
-   private void deleteJmsTopic(final ActionContext context) throws Exception {
-      performJmsManagement(new ManagementCallback<Message>() {
-         @Override
-         public void setUpInvocation(Message message) throws Exception {
-            JMSManagementHelper.putOperationInvocation(message, "jms.server", "destroyTopic", getName(), removeConsumers);
-         }
-
-         @Override
-         public void requestSuccessful(Message reply) throws Exception {
-            boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
-            if (result) {
-               context.out.println("Topic " + getName() + " deleted successfully.");
-            } else {
-               context.err.println("Failed to delete topic " + getName());
-            }
-         }
-
-         @Override
-         public void requestFailed(Message reply) throws Exception {
-            String errorMsg = (String) JMSManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to delete topic " + getName() + ". Reason: " + errorMsg);
-         }
-      });
-   }
-
-   private void deleteJmsQueue(final ActionContext context) throws Exception {
-      performJmsManagement(new ManagementCallback<Message>() {
-         @Override
-         public void setUpInvocation(Message message) throws Exception {
-            JMSManagementHelper.putOperationInvocation(message, "jms.server", "destroyQueue", getName(), removeConsumers);
-         }
-
-         @Override
-         public void requestSuccessful(Message reply) throws Exception {
-            boolean result = (boolean) JMSManagementHelper.getResult(reply, Boolean.class);
-            if (result) {
-               context.out.println("Jms queue " + getName() + " deleted successfully.");
-            } else {
-               context.err.println("Failed to delete queue " + getName());
-            }
-         }
-
-         @Override
-         public void requestFailed(Message reply) throws Exception {
-            String errorMsg = (String) JMSManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to create " + getName() + " with reason: " + errorMsg);
-         }
-      });
-   }
-
-   private void deleteCoreQueue(final ActionContext context) throws Exception {
-      performCoreManagement(new ManagementCallback<ClientMessage>() {
-         @Override
-         public void setUpInvocation(ClientMessage message) throws Exception {
-            ManagementHelper.putOperationInvocation(message, "core.server", "destroyQueue", getName());
-         }
-
-         @Override
-         public void requestSuccessful(ClientMessage reply) throws Exception {
-            context.out.println("Queue " + getName() + " deleted successfully.");
-         }
-
-         @Override
-         public void requestFailed(ClientMessage reply) throws Exception {
-            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
-            context.err.println("Failed to delete queue " + getName() + ". Reason: " + errMsg);
-         }
-      });
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java
deleted file mode 100644
index 55353d9..0000000
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/DestinationAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.artemis.cli.commands.destination;
-
-import javax.jms.Message;
-import javax.jms.Queue;
-import javax.jms.QueueRequestor;
-import javax.jms.Session;
-
-import io.airlift.airline.Option;
-import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.client.ClientRequestor;
-import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
-import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.api.core.management.ManagementHelper;
-import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
-import org.apache.activemq.artemis.cli.commands.messages.ConnectionAbstract;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-import org.apache.activemq.artemis.jms.client.ActiveMQSession;
-
-public abstract class DestinationAction extends ConnectionAbstract {
-
-   public static final String JMS_QUEUE = "jms-queue";
-   public static final String JMS_TOPIC = "topic";
-   public static final String CORE_QUEUE = "core-queue";
-
-   @Option(name = "--type", description = "type of destination to be created (one of jms-queue, topic and core-queue, default jms-queue")
-   String destType = JMS_QUEUE;
-
-   @Option(name = "--name", description = "destination name")
-   String name;
-
-   public void performJmsManagement(ManagementCallback<Message> cb) throws Exception {
-
-      try (ActiveMQConnectionFactory factory = createConnectionFactory();
-           ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
-           ActiveMQSession session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {
-
-         Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
-         QueueRequestor requestor = new QueueRequestor(session, managementQueue);
-
-         connection.start();
-
-         Message message = session.createMessage();
-
-         cb.setUpInvocation(message);
-
-         Message reply = requestor.request(message);
-
-         boolean result = JMSManagementHelper.hasOperationSucceeded(reply);
-
-         if (result) {
-            cb.requestSuccessful(reply);
-         } else {
-            cb.requestFailed(reply);
-         }
-      }
-   }
-
-   public void performCoreManagement(ManagementCallback<ClientMessage> cb) throws Exception {
-
-      try (ActiveMQConnectionFactory factory = createConnectionFactory();
-         ServerLocator locator = factory.getServerLocator();
-           ClientSessionFactory sessionFactory = locator.createSessionFactory();
-           ClientSession session = sessionFactory.createSession(user, password, false, true, true, false, ActiveMQClient.DEFAULT_ACK_BATCH_SIZE)) {
-         session.start();
-         ClientRequestor requestor = new ClientRequestor(session, "activemq.management");
-         ClientMessage message = session.createMessage(false);
-
-         cb.setUpInvocation(message);
-
-         ClientMessage reply = requestor.request(message);
-
-         if (ManagementHelper.hasOperationSucceeded(reply)) {
-            cb.requestSuccessful(reply);
-         } else {
-            cb.requestFailed(reply);
-         }
-      }
-   }
-
-   public void setName(String name) {
-      this.name = name;
-   }
-
-   public String getName() {
-      if (name == null) {
-         name = input("--name", "Please provide the destination name:", "");
-      }
-
-      return name;
-   }
-
-   public String getDestType() {
-      return destType;
-   }
-
-   public void setDestType(String destType) {
-      this.destType = destType;
-   }
-
-   public interface ManagementCallback<T> {
-
-      void setUpInvocation(T message) throws Exception;
-
-      void requestSuccessful(T reply) throws Exception;
-
-      void requestFailed(T reply) throws Exception;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java
deleted file mode 100644
index 3455520..0000000
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/destination/HelpDestination.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.artemis.cli.commands.destination;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import io.airlift.airline.Help;
-import org.apache.activemq.artemis.cli.commands.Action;
-import org.apache.activemq.artemis.cli.commands.ActionContext;
-
-public class HelpDestination extends Help implements Action {
-
-   @Override
-   public boolean isVerbose() {
-      return false;
-   }
-
-   @Override
-   public void setHomeValues(File brokerHome, File brokerInstance) {
-   }
-
-   @Override
-   public String getBrokerInstance() {
-      return null;
-   }
-
-   @Override
-   public String getBrokerHome() {
-      return null;
-   }
-
-   @Override
-   public Object execute(ActionContext context) throws Exception {
-      List<String> commands = new ArrayList<>(1);
-      commands.add("destination");
-      help(global, commands);
-      return null;
-   }
-}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/CreateQueue.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/CreateQueue.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/CreateQueue.java
new file mode 100644
index 0000000..76cea6e
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/CreateQueue.java
@@ -0,0 +1,117 @@
+/*
+ * 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.artemis.cli.commands.queue;
+
+import io.airlift.airline.Command;
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+
+@Command(name = "create", description = "create a queue or topic")
+public class CreateQueue extends AbstractAction {
+
+   @Option(name = "--name", description = "queue name")
+   String name;
+
+   @Option(name = "--filter", description = "queue's filter string (default null)")
+   String filter = null;
+
+   @Option(name = "--address", description = "address of the queue (default queue's name)")
+   String address;
+
+   @Option(name = "--durable", description = "whether the queue is durable or not (default false)")
+   boolean durable = false;
+
+   @Option(name = "--deleteOnNoConsumers", description = "whether to delete this queue when it's last consumers disconnects)")
+   boolean deleteOnNoConsumers = false;
+
+   @Option(name = "--maxConsumers", description = "Maximum number of consumers allowed on this queue at any one time (default no limit)")
+   int maxConsumers = -1;
+
+   @Option(name = "--autoCreateAddress", description = "Auto create the address (if it doesn't exist) with default values")
+   boolean autoCreateAddress = false;
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+      createQueue(context);
+      return null;
+   }
+
+   public String getAddress() {
+      if (address == null || "".equals(address.trim())) {
+         address = getName();
+      }
+      return address.trim();
+   }
+
+   private void createQueue(final ActionContext context) throws Exception {
+      performCoreManagement(new ManagementCallback<ClientMessage>() {
+         @Override
+         public void setUpInvocation(ClientMessage message) throws Exception {
+            String address = getAddress();
+            ManagementHelper.putOperationInvocation(message, "broker", "createQueue", address, getName(), filter, durable, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
+         }
+
+         @Override
+         public void requestSuccessful(ClientMessage reply) throws Exception {
+            context.out.println("Core queue " + getName() + " created successfully.");
+         }
+
+         @Override
+         public void requestFailed(ClientMessage reply) throws Exception {
+            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
+            context.err.println("Failed to create queue " + getName() + ". Reason: " + errMsg);
+         }
+      });
+   }
+
+   public void setFilter(String filter) {
+      this.filter = filter;
+   }
+
+   public void setAutoCreateAddress(boolean autoCreateAddress) {
+      this.autoCreateAddress = autoCreateAddress;
+   }
+
+   public void setMaxConsumers(int maxConsumers) {
+      this.maxConsumers = maxConsumers;
+   }
+
+   public void setDeleteOnNoConsumers(boolean deleteOnNoConsumers) {
+      this.deleteOnNoConsumers = deleteOnNoConsumers;
+   }
+
+   public void setAddress(String address) {
+      this.address = address;
+   }
+
+   public void setName(String name) {
+      this.name = name;
+   }
+
+   public String getName() {
+      if (name == null) {
+         name = input("--name", "Please provide the destination name:", "");
+      }
+
+      return name;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/DeleteQueue.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/DeleteQueue.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/DeleteQueue.java
new file mode 100644
index 0000000..19d2e99
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/DeleteQueue.java
@@ -0,0 +1,85 @@
+/*
+ * 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.artemis.cli.commands.queue;
+
+import io.airlift.airline.Command;
+import io.airlift.airline.Option;
+import org.apache.activemq.artemis.api.core.client.ClientMessage;
+import org.apache.activemq.artemis.api.core.management.ManagementHelper;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+import org.apache.activemq.artemis.cli.commands.AbstractAction;
+
+@Command(name = "delete", description = "delete a queue")
+public class DeleteQueue extends AbstractAction {
+
+   @Option(name = "--name", description = "queue name")
+   String name;
+
+   @Option(name = "--removeConsumers", description = "whether deleting destination with consumers or not (default false)")
+   boolean removeConsumers = false;
+
+   @Option(name = "--autoDeleteAddress", description = "delete the address if this it's last last queue")
+   boolean autoDeleteAddress = false;
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      super.execute(context);
+      deleteQueue(context);
+      return null;
+   }
+
+   private void deleteQueue(final ActionContext context) throws Exception {
+      performCoreManagement(new ManagementCallback<ClientMessage>() {
+         @Override
+         public void setUpInvocation(ClientMessage message) throws Exception {
+            ManagementHelper.putOperationInvocation(message, "broker", "destroyQueue", getName(), removeConsumers, autoDeleteAddress);
+         }
+
+         @Override
+         public void requestSuccessful(ClientMessage reply) throws Exception {
+            context.out.println("Queue " + getName() + " deleted successfully.");
+         }
+
+         @Override
+         public void requestFailed(ClientMessage reply) throws Exception {
+            String errMsg = (String) ManagementHelper.getResult(reply, String.class);
+            context.err.println("Failed to delete queue " + getName() + ". Reason: " + errMsg);
+         }
+      });
+   }
+
+   public void setRemoveConsumers(boolean removeConsumers) {
+      this.removeConsumers = removeConsumers;
+   }
+
+   public void setAutoDeleteAddress(boolean autoDeleteAddress) {
+      this.autoDeleteAddress = autoDeleteAddress;
+   }
+
+   public void setName(String name) {
+      this.name = name;
+   }
+
+   public String getName() {
+      if (name == null) {
+         name = input("--name", "Please provide the destination name:", "");
+      }
+
+      return name;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/HelpQueue.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/HelpQueue.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/HelpQueue.java
new file mode 100644
index 0000000..687e0f4
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/HelpQueue.java
@@ -0,0 +1,56 @@
+/*
+ * 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.artemis.cli.commands.queue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import io.airlift.airline.Help;
+import org.apache.activemq.artemis.cli.commands.Action;
+import org.apache.activemq.artemis.cli.commands.ActionContext;
+
+public class HelpQueue extends Help implements Action {
+
+   @Override
+   public boolean isVerbose() {
+      return false;
+   }
+
+   @Override
+   public void setHomeValues(File brokerHome, File brokerInstance) {
+   }
+
+   @Override
+   public String getBrokerInstance() {
+      return null;
+   }
+
+   @Override
+   public String getBrokerHome() {
+      return null;
+   }
+
+   @Override
+   public Object execute(ActionContext context) throws Exception {
+      List<String> commands = new ArrayList<>(1);
+      commands.add("queue");
+      help(global, commands);
+      return null;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
index eb3d48a..3c03ab2 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/ArtemisTest.java
@@ -538,13 +538,16 @@ public class ArtemisTest {
 
 
       // This is usually set when run from the command line via artemis.profile
-      Run.setEmbedded(true);
+      Run.setEmbedded(false);
       Artemis.main("create", instanceFolder.getAbsolutePath(), "--force", "--silent", "--no-web", "--queues", queues, "--topics", topics, "--no-autotune", "--require-login");
       System.setProperty("artemis.instance", instanceFolder.getAbsolutePath());
 
       // Some exceptions may happen on the initialization, but they should be ok on start the basic core protocol
       Artemis.internalExecute("run");
 
+      Artemis.main("queue", "create", "--name", "q1", "--address", "q1", "--user", "admin", "--password", "admin");
+      Artemis.main("queue", "create", "--name", "t2", "--address", "t2", "--user", "admin", "--password", "admin");
+
       try {
          try (ServerLocator locator = ServerLocatorImpl.newLocator("tcp://localhost:61616");
               ClientSessionFactory factory = locator.createSessionFactory();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressDoesNotExistException.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressDoesNotExistException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressDoesNotExistException.java
new file mode 100644
index 0000000..46a82b5
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQAddressDoesNotExistException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.artemis.api.core;
+
+/**
+ * An operation failed because an address exists on the server.
+ */
+public final class ActiveMQAddressDoesNotExistException extends ActiveMQException {
+
+   public ActiveMQAddressDoesNotExistException() {
+      super(ActiveMQExceptionType.ADDRESS_EXISTS);
+   }
+
+   public ActiveMQAddressDoesNotExistException(String msg) {
+      super(ActiveMQExceptionType.ADDRESS_EXISTS, msg);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDeleteAddressException.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDeleteAddressException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDeleteAddressException.java
new file mode 100644
index 0000000..9c80306
--- /dev/null
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQDeleteAddressException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.artemis.api.core;
+
+/**
+ * An operation failed because an address exists on the server.
+ */
+public final class ActiveMQDeleteAddressException extends ActiveMQException {
+
+   public ActiveMQDeleteAddressException() {
+      super(ActiveMQExceptionType.DELETE_ADDRESS_ERROR);
+   }
+
+   public ActiveMQDeleteAddressException(String msg) {
+      super(ActiveMQExceptionType.DELETE_ADDRESS_ERROR, msg);
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
index 6404c74..16e2b41 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQException.java
@@ -76,5 +76,4 @@ public class ActiveMQException extends Exception {
    public String toString() {
       return this.getClass().getSimpleName() + "[errorType=" + type + " message=" + getMessage() + "]";
    }
-
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
index 785dac3..64518ec 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/ActiveMQExceptionType.java
@@ -106,6 +106,12 @@ public enum ActiveMQExceptionType {
          return new ActiveMQSecurityException(msg);
       }
    },
+   ADDRESS_DOES_NOT_EXIST(106) {
+      @Override
+      public ActiveMQException createException(String msg) {
+         return new ActiveMQAddressDoesNotExistException(msg);
+      }
+   },
    ADDRESS_EXISTS(107) {
       @Override
       public ActiveMQException createException(String msg) {
@@ -231,6 +237,12 @@ public enum ActiveMQExceptionType {
       public ActiveMQException createException(String msg) {
          return new ActiveMQInvalidQueueConfiguration(msg);
       }
+   },
+   DELETE_ADDRESS_ERROR(217) {
+      @Override
+      public ActiveMQException createException(String msg) {
+         return new ActiveMQDeleteAddressException(msg);
+      }
    };
 
    private static final Map<Integer, ActiveMQExceptionType> TYPE_MAP;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
index 7772459..0654dbf 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java
@@ -19,6 +19,8 @@ package org.apache.activemq.artemis.api.core.management;
 import javax.management.MBeanOperationInfo;
 import java.util.Map;
 
+import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
+
 /**
  * An ActiveMQServerControl is used to manage ActiveMQ Artemis servers.
  */
@@ -438,6 +440,13 @@ public interface ActiveMQServerControl {
                       @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
                       @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception;
 
+
+   @Operation(desc = "create an address", impact = MBeanOperationInfo.ACTION)
+   void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
+                      @Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
+                      @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
+                      @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception;
+
    @Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
    void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;
 
@@ -455,6 +464,7 @@ public interface ActiveMQServerControl {
    void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
                     @Parameter(name = "name", desc = "Name of the queue") String name) throws Exception;
 
+
    /**
     * Create a queue.
     * <br>
@@ -490,6 +500,25 @@ public interface ActiveMQServerControl {
                     @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable) throws Exception;
 
    /**
+    * Create a queue.
+    * <br>
+    * If {@code address} is {@code null} it will be defaulted to {@code name}.
+    * <br>
+    * This method throws a {@link org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException}) exception if the queue already exits.
+    *
+    * @param address address to bind the queue to
+    * @param name    name of the queue
+    * @param durable whether the queue is durable
+    */
+   @Operation(desc = "Create a queue with the specified address, name and durability", impact = MBeanOperationInfo.ACTION)
+   void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
+                    @Parameter(name = "name", desc = "Name of the queue") String name,
+                    @Parameter(name = "filter", desc = "Filter of the queue") String filter,
+                    @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
+                    @Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
+                    @Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
+                    @Parameter(name = "autoCreateAddress", desc = "Create an address with default values should a matching address not be found") boolean autoCreateAddress) throws Exception;
+   /**
     * Deploy a durable queue.
     * <br>
     * If {@code address} is {@code null} it will be defaulted to {@code name}.
@@ -537,6 +566,14 @@ public interface ActiveMQServerControl {
                      @Parameter(name = "removeConsumers", desc = "Remove consumers of this queue") boolean removeConsumers) throws Exception;
 
    /**
+    * Destroys the queue corresponding to the specified name and delete it's address if there are no other queues
+    */
+   @Operation(desc = "Destroy a queue", impact = MBeanOperationInfo.ACTION)
+   void destroyQueue(@Parameter(name = "name", desc = "Name of the queue to destroy") String name,
+                     @Parameter(name = "removeConsumers", desc = "Remove consumers of this queue") boolean removeConsumers, boolean autoDeleteAddress) throws Exception;
+
+
+   /**
     * Enables message counters for this server.
     */
    @Operation(desc = "Enable message counters", impact = MBeanOperationInfo.ACTION)
@@ -901,5 +938,10 @@ public interface ActiveMQServerControl {
 
    @Operation(desc = "List the Network Topology", impact = MBeanOperationInfo.INFO)
    String listNetworkTopology() throws Exception;
+
+   String getAddressInfo(String address) throws ActiveMQAddressDoesNotExistException;
+
+   @Operation(desc = "Get a list of bindings associated with an address", impact = MBeanOperationInfo.INFO)
+   String[] listBindingsForAddress(String address) throws Exception;
 }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index a183187..c38b2cf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -42,6 +42,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
@@ -49,6 +50,7 @@ import org.apache.activemq.artemis.api.core.management.AddressControl;
 import org.apache.activemq.artemis.api.core.management.BridgeControl;
 import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
 import org.apache.activemq.artemis.api.core.management.DivertControl;
+import org.apache.activemq.artemis.api.core.management.Parameter;
 import org.apache.activemq.artemis.api.core.management.QueueControl;
 import org.apache.activemq.artemis.core.client.impl.Topology;
 import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
@@ -62,8 +64,10 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
 import org.apache.activemq.artemis.core.persistence.config.PersistedAddressSetting;
 import org.apache.activemq.artemis.core.persistence.config.PersistedRoles;
 import org.apache.activemq.artemis.core.postoffice.Binding;
+import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.postoffice.DuplicateIDCache;
 import org.apache.activemq.artemis.core.postoffice.PostOffice;
+import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding;
 import org.apache.activemq.artemis.core.remoting.server.RemotingService;
 import org.apache.activemq.artemis.core.security.CheckType;
@@ -71,6 +75,7 @@ import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
+import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.ConnectorServiceFactory;
 import org.apache.activemq.artemis.core.server.Consumer;
 import org.apache.activemq.artemis.core.server.JournalType;
@@ -562,13 +567,22 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
 
       clearIO();
       try {
-         server.createOrUpdateAddressInfo(new AddressInfo(new SimpleString(name), AddressInfo.RoutingType.getType((byte)routingType), defaultDeleteOnNoConsumers, defaultMaxConsumers));
+         server.createAddressInfo(new AddressInfo(new SimpleString(name), AddressInfo.RoutingType.getType((byte) routingType), defaultDeleteOnNoConsumers, defaultMaxConsumers));
       } finally {
          blockOnIO();
       }
    }
 
    @Override
+   public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
+                             @Parameter(name = "routingType", desc = "The routing type for the address either 'MULTICAST' or 'ANYCAST'") String routingType,
+                             @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers,
+                             @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception {
+      AddressInfo.RoutingType rt = AddressInfo.RoutingType.valueOf(routingType.toUpperCase());
+      createAddress(name, rt.ordinal(), defaultDeleteOnNoConsumers, defaultMaxConsumers);
+   }
+
+   @Override
    public void deleteAddress(String name) throws Exception {
       checkStarted();
 
@@ -633,6 +647,30 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
    }
 
    @Override
+   public void createQueue(@Parameter(name = "address", desc = "Address of the queue") String address,
+                           @Parameter(name = "name", desc = "Name of the queue") String name,
+                           @Parameter(name = "filter", desc = "Filter of the queue") String filterStr,
+                           @Parameter(name = "durable", desc = "Is the queue durable?") boolean durable,
+                           @Parameter(name = "maxConsumers", desc = "The maximum number of consumers allowed on this queue at any one time") int maxConsumers,
+                           @Parameter(name = "deleteOnNoConsumers", desc = "Delete this queue when the last consumer disconnects") boolean deleteOnNoConsumers,
+                           @Parameter(name = "autoCreateAddress", desc = "Create an address with default values if one does not exist") boolean autoCreateAddress) throws Exception {
+      checkStarted();
+
+      clearIO();
+
+      SimpleString filter = filterStr == null ? null : new SimpleString(filterStr);
+      try {
+         if (filterStr != null && !filterStr.trim().equals("")) {
+            filter = new SimpleString(filterStr);
+         }
+
+         server.createQueue(SimpleString.toSimpleString(address), new SimpleString(name), filter, durable, false, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
+      } finally {
+         blockOnIO();
+      }
+   }
+
+   @Override
    public void createQueue(final String address,
                            final String name,
                            final String filterStr,
@@ -727,24 +765,52 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
    }
 
    @Override
-   public void destroyQueue(final String name, final boolean removeConsumers) throws Exception {
+   public void destroyQueue(final String name, final boolean removeConsumers, final boolean autoDeleteAddress) throws Exception {
       checkStarted();
 
       clearIO();
       try {
          SimpleString queueName = new SimpleString(name);
-         server.destroyQueue(queueName, null, !removeConsumers, removeConsumers);
+         server.destroyQueue(queueName, null, !removeConsumers, removeConsumers, autoDeleteAddress);
       } finally {
          blockOnIO();
       }
    }
 
    @Override
+   public void destroyQueue(final String name, final boolean removeConsumers) throws Exception {
+      destroyQueue(name, removeConsumers, false);
+   }
+
+   @Override
    public void destroyQueue(final String name) throws Exception {
       destroyQueue(name, false);
    }
 
    @Override
+   public String getAddressInfo(String address) throws ActiveMQAddressDoesNotExistException {
+      AddressInfo addressInfo = server.getAddressInfo(SimpleString.toSimpleString(address));
+      if (addressInfo == null) {
+         throw ActiveMQMessageBundle.BUNDLE.addressDoesNotExist(SimpleString.toSimpleString(address));
+      }
+      else {
+         return addressInfo.toString();
+      }
+   }
+
+   @Override
+   public String[] listBindingsForAddress(String address) throws Exception {
+      Bindings bindings = server.getPostOffice().getBindingsForAddress(new SimpleString(address));
+      List<String> result = new ArrayList<>(bindings.getBindings().size());
+
+      int i = 0;
+      for (Binding binding : bindings.getBindings()) {
+
+      }
+      return (String[]) result.toArray();
+   }
+
+   @Override
    public int getConnectionCount() {
       checkStarted();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
index f1225c1..48ec7db 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.artemis.core.postoffice;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -50,6 +51,8 @@ public interface PostOffice extends ActiveMQComponent {
 
    AddressInfo getAddressInfo(SimpleString address);
 
+   List<Queue> listQueuesForAddress(SimpleString address) throws Exception;
+
    void addBinding(Binding binding) throws Exception;
 
    Binding removeBinding(SimpleString uniqueName, Transaction tx, boolean deleteData) throws Exception;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
index 135597f..3064363 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java
@@ -54,6 +54,7 @@ import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.postoffice.BindingsFactory;
 import org.apache.activemq.artemis.core.postoffice.DuplicateIDCache;
 import org.apache.activemq.artemis.core.postoffice.PostOffice;
+import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.postoffice.QueueInfo;
 import org.apache.activemq.artemis.core.postoffice.RoutingStatus;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
@@ -131,6 +132,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
 
    private final ActiveMQServer server;
 
+   private Object addressLock = new Object();
+
    public PostOfficeImpl(final ActiveMQServer server,
                          final StorageManager storageManager,
                          final PagingManager pagingManager,
@@ -420,39 +423,61 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
 
    @Override
    public AddressInfo addAddressInfo(AddressInfo addressInfo) {
-      try {
-         managementService.registerAddress(addressInfo);
-      } catch (Exception e) {
-         e.printStackTrace();
+      synchronized (addressLock) {
+         try {
+            managementService.registerAddress(addressInfo);
+         } catch (Exception e) {
+            e.printStackTrace();
+         }
+         return addressManager.addAddressInfo(addressInfo);
       }
-      return addressManager.addAddressInfo(addressInfo);
    }
 
    @Override
    public AddressInfo addOrUpdateAddressInfo(AddressInfo addressInfo) {
-      try {
-         managementService.registerAddress(addressInfo);
-      } catch (Exception e) {
-         e.printStackTrace();
+      synchronized (addressLock) {
+         try {
+            managementService.registerAddress(addressInfo);
+         } catch (Exception e) {
+            e.printStackTrace();
+         }
+         return addressManager.addOrUpdateAddressInfo(addressInfo);
       }
-      return addressManager.addOrUpdateAddressInfo(addressInfo);
    }
 
    @Override
-   public AddressInfo removeAddressInfo(SimpleString address) {
-      try {
-         getServer().getManagementService().unregisterAddress(address);
-      } catch (Exception e) {
-         e.printStackTrace();
+   public AddressInfo removeAddressInfo(SimpleString address) throws Exception {
+      synchronized (addressLock) {
+         Bindings bindingsForAddress = getBindingsForAddress(address);
+         if (bindingsForAddress.getBindings().size() > 0) {
+            throw new IllegalStateException("Address has bindings");
+         }
+         managementService.unregisterAddress(address);
+         return addressManager.removeAddressInfo(address);
       }
-      return addressManager.removeAddressInfo(address);
    }
 
    @Override
    public AddressInfo getAddressInfo(SimpleString addressName) {
-      return addressManager.getAddressInfo(addressName);
+      synchronized (addressLock) {
+         return addressManager.getAddressInfo(addressName);
+      }
    }
 
+   @Override
+   public List<Queue> listQueuesForAddress(SimpleString address) throws Exception {
+      Bindings bindingsForAddress = getBindingsForAddress(address);
+      List<Queue> queues = new ArrayList<>();
+      for (Binding b : bindingsForAddress.getBindings()) {
+         if (b instanceof QueueBinding) {
+            Queue q = ((QueueBinding) b).getQueue();
+            queues.add(q);
+         }
+      }
+      return queues;
+   }
+
+
    // TODO - needs to be synchronized to prevent happening concurrently with activate()
    // (and possible removeBinding and other methods)
    // Otherwise can have situation where createQueue comes in before failover, then failover occurs

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
index 6d8cf30..5d39df0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQMessageBundle.java
@@ -18,9 +18,12 @@ package org.apache.activemq.artemis.core.server;
 
 import java.io.File;
 
+import org.apache.activemq.artemis.api.core.ActiveMQAddressDoesNotExistException;
+import org.apache.activemq.artemis.api.core.ActiveMQAddressExistsException;
 import org.apache.activemq.artemis.api.core.ActiveMQAddressFullException;
 import org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException;
 import org.apache.activemq.artemis.api.core.ActiveMQConnectionTimedOutException;
+import org.apache.activemq.artemis.api.core.ActiveMQDeleteAddressException;
 import org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException;
 import org.apache.activemq.artemis.api.core.ActiveMQDuplicateMetaDataException;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
@@ -390,4 +393,13 @@ public interface ActiveMQMessageBundle {
 
    @Message(id = 119202, value = "Invalid Queue Configuration for Queue {0}, Address {1}.  Expected {2} to be {3} but was {4}", format = Message.Format.MESSAGE_FORMAT)
    ActiveMQInvalidQueueConfiguration invalidQueueConfiguration(SimpleString address, SimpleString queueName, String queuePropertyName, Object expectedValue, Object actualValue);
+
+   @Message(id = 119203, value = "Address Does Not Exist: {0}", format = Message.Format.MESSAGE_FORMAT)
+   ActiveMQAddressDoesNotExistException addressDoesNotExist(SimpleString address);
+
+   @Message(id = 119204, value = "Address already exists: {0}", format = Message.Format.MESSAGE_FORMAT)
+   ActiveMQAddressExistsException addressAlreadyExists(SimpleString address);
+
+   @Message(id = 119205, value = "Address {0} has bindings", format = Message.Format.MESSAGE_FORMAT)
+   ActiveMQDeleteAddressException addressHasBindings(SimpleString address);
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec8f0613/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
index 84f554d..833f8ce 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java
@@ -22,6 +22,7 @@ import java.util.Set;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+import com.google.common.collect.Queues;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.config.BridgeConfiguration;
 import org.apache.activemq.artemis.core.config.Configuration;
@@ -122,6 +123,12 @@ public interface ActiveMQServer extends ActiveMQComponent {
     */
    ActiveMQServerControlImpl getActiveMQServerControl();
 
+   void destroyQueue(SimpleString queueName,
+                     SecurityAuth session,
+                     boolean checkConsumerCount,
+                     boolean removeConsumers,
+                     boolean autoDeleteAddress) throws Exception;
+
    void registerActivateCallback(ActivateCallback callback);
 
    void unregisterActivateCallback(ActivateCallback callback);
@@ -289,7 +296,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
                      boolean durable,
                      boolean temporary,
                      Integer maxConsumers,
-                     Boolean deleteOnNoConsumers) throws Exception;
+                     Boolean deleteOnNoConsumers,
+                     boolean autoCreateAddress) throws Exception;
 
    Queue createQueue(SimpleString address,
                      SimpleString queueName,
@@ -305,7 +313,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
                      boolean durable,
                      boolean temporary,
                      Integer maxConsumers,
-                     Boolean deleteOnNoConsumers) throws Exception;
+                     Boolean deleteOnNoConsumers,
+                     boolean autoCreateAddress) throws Exception;
 
    Queue createQueue(SimpleString address,
                      SimpleString queueName,
@@ -323,7 +332,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
                      boolean temporary,
                      boolean autoCreated,
                      Integer maxConsumers,
-                     Boolean deleteOnNoConsumers) throws Exception;
+                     Boolean deleteOnNoConsumers,
+                     boolean autoCreateAddress) throws Exception;
 
    Queue deployQueue(SimpleString address,
                      SimpleString queueName,
@@ -351,7 +361,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
                      boolean temporary,
                      boolean autoCreated,
                      Integer maxConsumers,
-                     Boolean deleteOnNoConsumers) throws Exception;
+                     Boolean deleteOnNoConsumers,
+                     boolean autoCreateAddress) throws Exception;
 
    void destroyQueue(SimpleString queueName) throws Exception;
 
@@ -414,7 +425,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
                      boolean transientQueue,
                      boolean autoCreated,
                      Integer maxConsumers,
-                     Boolean deleteOnNoConsumers) throws Exception;
+                     Boolean deleteOnNoConsumers,
+                     boolean autoCreateAddress) throws Exception;
 
    /*
          * add a ProtocolManagerFactory to be used. Note if @see Configuration#isResolveProtocols is tur then this factory will
@@ -451,6 +463,8 @@ public interface ActiveMQServer extends ActiveMQComponent {
 
    AddressInfo putAddressInfoIfAbsent(AddressInfo addressInfo) throws Exception;
 
+   void createAddressInfo(AddressInfo addressInfo) throws Exception;
+
    AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception;
 
    void removeAddressInfo(SimpleString address) throws Exception;