activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [19/24] activemq-artemis git commit: ARTEMIS-178 Refactor examples to use CLI
Date Wed, 29 Jul 2015 21:22:25 GMT
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/colocated-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover/pom.xml b/examples/jms/colocated-failover/pom.xml
index 5860edf..fb697b2 100644
--- a/examples/jms/colocated-failover/pom.xml
+++ b/examples/jms/colocated-failover/pom.xml
@@ -57,34 +57,23 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start0</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                           <systemProperties>
-                              <property>
-                                 <name>udp-address</name>
-                                 <value>${udp-address}</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
-                        <id>start1</id>
+                        <id>create2</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
-                           <fork>true</fork>
-                           <systemProperties>
-                              <property>
-                                 <name>udp-address</name>
-                                 <value>${udp-address}</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server1</instance>
+                           <configuration>${basedir}/target/classes/activemq/server1</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -95,33 +84,9 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.ColocatedFailoverExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
-                              <param>tcp://localhost:61617</param>
+                              <param>${basedir}/target/server0</param>
+                              <param>${basedir}/target/server1</param>
                            </args>
-                            <systemProperties>
-                                <property>
-                                    <name>exampleConfigDir</name>
-                                    <value>${basedir}/target/classes/activemq</value>
-                                </property>
-                            </systemProperties>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop0</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop1</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
                         </configuration>
                      </execution>
                   </executions>
@@ -131,40 +96,7 @@ under the License.
                         <artifactId>colocated-failover</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java b/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java
index 0baa7b4..de823a4 100644
--- a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java
+++ b/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import java.util.Hashtable;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.MessageConsumer;
@@ -26,6 +24,7 @@ import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.InitialContext;
+import java.util.Hashtable;
 
 import org.apache.activemq.artemis.common.example.ActiveMQExample;
 
@@ -35,7 +34,7 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample;
  */
 public class ColocatedFailoverExample extends ActiveMQExample
 {
-   public static void main(final String[] args)
+   public static void main(final String[] args) throws Exception
    {
       new ColocatedFailoverExample().run(args);
    }
@@ -56,12 +55,12 @@ public class ColocatedFailoverExample extends ActiveMQExample
          // Step 1. Get an initial context for looking up JNDI for both servers
          Hashtable<String, Object> properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[1]);
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2);
          initialContext1 = new InitialContext(properties);
 
          properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[0] + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
          properties.put("queue.queue/exampleQueue", "exampleQueue");
          initialContext = new InitialContext(properties);
 
@@ -95,8 +94,8 @@ public class ColocatedFailoverExample extends ActiveMQExample
 
          // Step 7. Crash server #0, the live server, and wait a little while to make sure
          // it has really crashed
-         Thread.sleep(2000);
          killServer(0);
+         Thread.sleep(5000);
 
 
          // Step 8. start the connection ready to receive messages

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml
index 363ae96..554d01f 100644
--- a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml
@@ -30,13 +30,13 @@ under the License.
    <core xmlns="urn:activemq:core">
 
 
-      <bindings-directory>target/server0/data/messaging/bindings</bindings-directory>
+      <bindings-directory>../../server0/data/messaging/bindings</bindings-directory>
 
-      <journal-directory>target/server0/data/messaging/journal</journal-directory>
+      <journal-directory>../../server0/data/messaging/journal</journal-directory>
 
-      <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory>
+      <large-messages-directory>../../server0/data/messaging/largemessages</large-messages-directory>
 
-      <paging-directory>target/server0/data/messaging/paging</paging-directory>
+      <paging-directory>../../server0/data/messaging/paging</paging-directory>
       <!-- Connectors -->
 
       <connectors>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml
index 464fdee..2fda160 100644
--- a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml
@@ -30,13 +30,13 @@ under the License.
    <core xmlns="urn:activemq:core">
 
 
-      <bindings-directory>target/server1/data/messaging/bindings</bindings-directory>
+      <bindings-directory>../../server1/data/messaging/bindings</bindings-directory>
 
-      <journal-directory>target/server1/data/messaging/journal</journal-directory>
+      <journal-directory>../../server1/data/messaging/journal</journal-directory>
 
-      <large-messages-directory>target/server1/data/messaging/largemessages</large-messages-directory>
+      <large-messages-directory>../../server1/data/messaging/largemessages</large-messages-directory>
 
-      <paging-directory>target/server1/data/messaging/paging</paging-directory>
+      <paging-directory>../../server1/data/messaging/paging</paging-directory>
 
       <!-- Connectors -->
       <connectors>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/common/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/common/pom.xml b/examples/jms/common/pom.xml
index 9fe2604..4681cac 100644
--- a/examples/jms/common/pom.xml
+++ b/examples/jms/common/pom.xml
@@ -55,6 +55,11 @@ under the License.
          <artifactId>artemis-jms-client</artifactId>
          <version>${project.version}</version>
       </dependency>
+      <dependency>
+         <groupId>io.netty</groupId>
+         <artifactId>netty-all</artifactId>
+         <version>${netty.version}</version>
+      </dependency>
    </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java
index 637cf3b..b3b791b 100644
--- a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java
+++ b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ActiveMQExample.java
@@ -16,156 +16,214 @@
  */
 package org.apache.activemq.artemis.common.example;
 
-import java.io.File;
+import javax.jms.Connection;
 import java.util.HashMap;
 import java.util.logging.Logger;
 
-import javax.jms.Connection;
-import javax.jms.JMSException;
-
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ClientSession;
 import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
 import org.apache.activemq.artemis.api.jms.JMSFactoryType;
-import org.apache.activemq.artemis.core.client.impl.DelegatingSession;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 
 /**
- * Base class for ActiveMQ Artemis examples.
- * <p>
- * This takes care of starting and stopping the server as well as deploying any
- * queue needed.
+ * This cass is a base class for all the tests where we have a few utilities to start and stop servers *
  */
 public abstract class ActiveMQExample
 {
    protected static final Logger log = Logger.getLogger(ActiveMQExample.class.getName());
+   public static final int DEFAULT_PORT = 61616;
+
+   public static final String DEFAULT_TCP1 = "tcp://localhost:61616";
+   public static final String DEFAULT_TCP2 = "tcp://localhost:61617";
+   public static final String DEFAULT_TCP3 = "tcp://localhost:61618";
+   public static final String DEFAULT_TCP4 = "tcp://localhost:61619";
 
    protected boolean failure = false;
 
-   protected String[] args;
+   protected String[] serversArgs;
 
-   public abstract boolean runExample() throws Exception;
+   protected Process[] processes;
 
-   protected void run(final String[] args1)
-   {
-      this.args = args1;
-      //if we have a cluster of servers wait a while for the cluster to form properly
-      if(args != null && args.length > 1)
-      {
-         System.out.println("****pausing to allow cluster to form****");
-         Thread.yield();
-         try
-         {
-            Thread.sleep(2000);
-         }
-         catch (InterruptedException e)
-         {
-            //ignore
-         }
-      }
 
+   // This is to make sure we stop the servers when the example is shutdown
+   // as we start the servers with the example
+   Thread hook;
+
+   public void run(String servers[])
+   {
       try
       {
+         setupServers(servers);
          if (!runExample())
          {
             failure = true;
          }
-         System.out.println("example complete");
       }
-      catch (Throwable e)
+      catch (Throwable throwable)
       {
          failure = true;
-         e.printStackTrace();
+         throwable.printStackTrace();
       }
+      finally
+      {
+         try
+         {
+            stopAllServers();
+         }
+         catch (Throwable ignored)
+         {
+            ignored.printStackTrace();
+         }
+      }
+
       reportResultAndExit();
+
    }
+   public abstract boolean runExample() throws Exception;
 
-   protected void killServer(final int id) throws Exception
+   public void close() throws Exception
    {
-      String configDir = System.getProperty("exampleConfigDir");
-      if(configDir == null)
+
+      if (hook != null)
       {
-         throw new Exception("exampleConfigDir must be set as a system property");
+         Runtime.getRuntime().removeShutdownHook(hook);
+         hook = null;
       }
+      stopAllServers();
+   }
+
+   /** This will start the servers */
+   private final ActiveMQExample setupServers(String[] serversArgs) throws Exception
+   {
+      hook = new Thread()
+      {
+         public void run()
+         {
+            try
+            {
+               System.out.println("Shutting down servers!!!");
+               System.out.flush();
+               ActiveMQExample.this.stopAllServers();
+            }
+            catch (Exception e)
+            {
+               e.printStackTrace();
+            }
+         }
+      };
 
-      System.out.println("Killing server " + id);
+      Runtime.getRuntime().addShutdownHook(hook);
+      this.serversArgs = serversArgs;
 
-      // We kill the server by creating a new file in the server dir which is checked for by the server
-      // We can't use Process.destroy() since this does not do a hard kill - it causes shutdown hooks
-      // to be called which cleanly shutdown the server
-      System.out.println(configDir + "/server" + id + "/KILL_ME");
-      File file = new File(configDir + "/server" + id + "/KILL_ME");
+      if (serversArgs == null)
+      {
+         serversArgs = new String[0];
+      }
 
-      file.createNewFile();
+      processes = new Process[serversArgs.length];
+      startServers(serversArgs);
 
-      // Sleep longer than the KillChecker check period
-      Thread.sleep(3000);
+      return this;
    }
 
-   protected void killServer(final int id, final int serverToWaitFor) throws Exception
+   protected void startServers(String[] serversArgs) throws Exception
    {
-      String configDir = System.getProperty("exampleConfigDir");
-      if(configDir == null)
+      for (int i = 0; i < serversArgs.length; i++)
       {
-         throw new Exception("exampleConfigDir must be set as a system property");
+         startServer(i, 5000);
       }
+   }
 
-      System.out.println("Killing server " + id);
-
-      // We kill the server by creating a new file in the server dir which is checked for by the server
-      // We can't use Process.destroy() since this does not do a hard kill - it causes shutdown hooks
-      // to be called which cleanly shutdown the server
-      System.out.println(configDir + "/server" + id + "/KILL_ME");
-      File file = new File(configDir + "/server" + id + "/KILL_ME");
-
-      file.createNewFile();
-
-      waitForServerStart(serverToWaitFor, 20000);
+   protected void stopAllServers() throws Exception
+   {
+      if (processes != null)
+      {
+         for (int i = 0; i < processes.length; i++)
+         {
+            killServer(i);
+         }
+      }
    }
 
-   protected void reStartServer(final int id, final long timeout) throws Exception
+   protected void killServer(final int id) throws Exception
    {
-      String configDir = System.getProperty("exampleConfigDir");
-      if(configDir == null)
+      if (id > processes.length)
       {
-         throw new Exception("exampleConfigDir must be set as a system property");
+         System.out.println("**********************************");
+         System.out.println("Kill server " + id + " manually, will wait 5 seconds for that being done");
+         Thread.sleep(5000);
       }
 
-      System.out.println("restarting server " + id);
+      if (processes[id] != null)
+      {
+         System.out.println("**********************************");
+         System.out.println("Kill server " + id);
+         processes[id].destroyForcibly();
+         processes[id].waitFor();
+//         processes[id].destroy();
+         processes[id] = null;
+         Thread.sleep(1000);
+      }
+   }
 
-      // We kill the server by creating a new file in the server dir which is checked for by the server
-      // We can't use Process.destroy() since this does not do a hard kill - it causes shutdown hooks
-      // to be called which cleanly shutdown the server
-      File file = new File(configDir + "/server" + id + "/RESTART_ME");
+   protected void reStartServer(final int id, final long timeout) throws Exception
+   {
+      startServer(id, timeout);
+   }
 
-      file.createNewFile();
+   protected void startServer(final int id, final long timeout) throws Exception
+   {
+      if (id > processes.length)
+      {
+         System.out.println("**********************************");
+         System.out.println("Start server " + id + " manually");
+         Thread.sleep(5000);
+      }
+      else
+      {
+         // if started before, will kill it
+         if (processes[id] != null)
+         {
+            killServer(id);
+         }
+      }
 
-      waitForServerStart(id, timeout);
+      processes[id] = ExampleUtil.startServer(serversArgs[id], "Server_" + id);
 
+      if (timeout != 0)
+      {
+         waitForServerStart(id, timeout);
+      }
+      else
+      {
+         // just some time wait to wait server to form clusters.. etc
+         Thread.sleep(500);
+      }
    }
 
-   private void waitForServerStart(int id, long timeout) throws InterruptedException
+   protected void waitForServerStart(int id, long timeoutParameter) throws InterruptedException
    {
       // wait for restart
-      long time = System.currentTimeMillis();
-      while (time < System.currentTimeMillis() + timeout)
+      long timeout = System.currentTimeMillis() + timeoutParameter;
+      while (System.currentTimeMillis() < timeout)
       {
          try
          {
             HashMap<String, Object> params = new HashMap<String, Object>();
             params.put("host", "localhost");
-            params.put("port", 61616 + id);
+            params.put("port", DEFAULT_PORT + id);
             TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
             ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
             cf.createConnection().close();
-            System.out.println("server restarted");
+            System.out.println("server " + id + " started");
          }
          catch (Exception e)
          {
-            System.out.println("awaiting server restart");
-            Thread.sleep(1000);
+            System.out.println("awaiting server " + id + " start at " + (DEFAULT_PORT + id));
+            Thread.sleep(500);
             continue;
          }
          break;
@@ -177,7 +235,7 @@ public abstract class ActiveMQExample
       ClientSession session = ((ActiveMQConnection) connection).getInitialSession();
       TransportConfiguration transportConfiguration = session.getSessionFactory().getConnectorConfiguration();
       String port = (String) transportConfiguration.getParams().get("port");
-      return Integer.valueOf(port) - 61616;
+      return Integer.valueOf(port) - DEFAULT_PORT;
    }
 
    protected Connection getServerConnection(int server, Connection... connections)
@@ -213,12 +271,4 @@ public abstract class ActiveMQExample
          System.out.println("#####################");
       }
    }
-
-   protected static final void closeConnection(final Connection connection) throws JMSException
-   {
-      if (connection != null)
-      {
-         connection.close();
-      }
-   }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java
----------------------------------------------------------------------
diff --git a/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java
new file mode 100644
index 0000000..b9bb25d
--- /dev/null
+++ b/examples/jms/common/src/main/java/org/apache/activemq/artemis/common/example/ExampleUtil.java
@@ -0,0 +1,122 @@
+/**
+ * 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.common.example;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class ExampleUtil
+{
+   public static Process startServer(String artemisInstance, String serverName) throws Exception
+   {
+      boolean IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");
+
+      ProcessBuilder builder = null;
+      if (IS_WINDOWS)
+      {
+         builder = new ProcessBuilder("cmd", "/c", "artemis.cmd", "run");
+      }
+      else
+      {
+         builder = new ProcessBuilder("./artemis", "run");
+      }
+
+      builder.directory(new File(artemisInstance + "/bin"));
+
+      Process process = builder.start();
+
+      ProcessLogger outputLogger = new ProcessLogger(true,
+                                                     process.getInputStream(),
+                                                     serverName + "::Out",
+                                                     false);
+      outputLogger.start();
+
+      // Adding a reader to System.err, so the VM won't hang on a System.err.println as identified on this forum thread:
+      // http://www.jboss.org/index.html?module=bb&op=viewtopic&t=151815
+      ProcessLogger errorLogger = new ProcessLogger(true,
+                                                    process.getErrorStream(),
+                                                    serverName + "::Err",
+                                                    true);
+      errorLogger.start();
+
+      return process;
+   }
+
+
+   /**
+    * Redirect the input stream to a logger (as debug logs)
+    */
+   static class ProcessLogger extends Thread
+   {
+      private final InputStream is;
+
+      private final String logName;
+
+      private final boolean print;
+
+      private final boolean sendToErr;
+
+      boolean failed = false;
+
+      ProcessLogger(final boolean print,
+                    final InputStream is,
+                    final String logName,
+                    final boolean sendToErr) throws ClassNotFoundException
+      {
+         this.is = is;
+         this.print = print;
+         this.logName = logName;
+         this.sendToErr = sendToErr;
+         setDaemon(false);
+      }
+
+      @Override
+      public void run()
+      {
+         try
+         {
+            InputStreamReader isr = new InputStreamReader(is);
+            BufferedReader br = new BufferedReader(isr);
+            String line;
+            while ((line = br.readLine()) != null)
+            {
+               if (print)
+               {
+                  if (sendToErr)
+                  {
+                     System.err.println(logName + " err:" + line);
+                  }
+                  else
+                  {
+                     System.out.println(logName + " out:" + line);
+                  }
+               }
+            }
+         }
+         catch (IOException e)
+         {
+            // ok, stream closed
+         }
+
+      }
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/consumer-rate-limit/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/consumer-rate-limit/pom.xml b/examples/jms/consumer-rate-limit/pom.xml
index 6e4690b..d262b3b 100644
--- a/examples/jms/consumer-rate-limit/pom.xml
+++ b/examples/jms/consumer-rate-limit/pom.xml
@@ -57,17 +57,13 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <systemProperties>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -78,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.ConsumerRateLimitExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -95,41 +85,7 @@ under the License.
                         <artifactId>artemis-jms-consumer-rate-limit-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/dead-letter/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/dead-letter/pom.xml b/examples/jms/dead-letter/pom.xml
index bcec76a..c383d9e 100644
--- a/examples/jms/dead-letter/pom.xml
+++ b/examples/jms/dead-letter/pom.xml
@@ -57,17 +57,13 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <systemProperties>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -78,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.DeadLetterExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -95,41 +85,7 @@ under the License.
                         <artifactId>artemis-jms-dead-letter-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/delayed-redelivery/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/delayed-redelivery/pom.xml b/examples/jms/delayed-redelivery/pom.xml
index 1d696c9..4264468 100644
--- a/examples/jms/delayed-redelivery/pom.xml
+++ b/examples/jms/delayed-redelivery/pom.xml
@@ -57,10 +57,14 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
+                        <configuration>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
+                        </configuration>
                      </execution>
                      <execution>
                         <id>runClient</id>
@@ -70,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.DelayedRedeliveryExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -87,47 +85,7 @@ under the License.
                         <artifactId>artemis-jms-delayed-redelivery-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                     <systemProperties>
-                        <property>
-                           <name>data.dir</name>
-                           <value>${basedir}/target/</value>
-                        </property>
-                     </systemProperties>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/divert/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/divert/pom.xml b/examples/jms/divert/pom.xml
index d1007d6..260569e 100644
--- a/examples/jms/divert/pom.xml
+++ b/examples/jms/divert/pom.xml
@@ -62,22 +62,23 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start0</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
-                        <id>start1</id>
+                        <id>create2</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
-                           <fork>true</fork>
+                           <instance>${basedir}/target/server1</instance>
+                           <configuration>${basedir}/target/classes/activemq/server1</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -88,33 +89,9 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.DivertExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
-                              <param>tcp://localhost:61617</param>
+                              <param>${basedir}/target/server0</param>
+                              <param>${basedir}/target/server1</param>
                            </args>
-                           <systemProperties>
-                              <property>
-                                 <name>exampleConfigDir</name>
-                                 <value>${basedir}/target/classes/activemq</value>
-                              </property>
-                           </systemProperties>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop0</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop1</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
                         </configuration>
                      </execution>
                   </executions>
@@ -124,46 +101,7 @@ under the License.
                         <artifactId>artemis-jms-divert-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <systemProperties>
-                        <property>
-                           <name>data.dir</name>
-                           <value>${basedir}/target/</value>
-                        </property>
-                     </systemProperties>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java b/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java
index a4cc663..503aadd 100644
--- a/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java
+++ b/examples/jms/divert/src/main/java/org/apache/activemq/artemis/jms/example/DivertExample.java
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import java.util.Hashtable;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.Message;
@@ -28,6 +26,7 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.Topic;
 import javax.naming.InitialContext;
+import java.util.Hashtable;
 
 import org.apache.activemq.artemis.common.example.ActiveMQExample;
 
@@ -59,7 +58,7 @@ public class DivertExample extends ActiveMQExample
          // Step 1. Create an initial context to perform the JNDI lookup on the London server
          Hashtable<String, Object> properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[0]);
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1);
          properties.put("queue.queue/orders", "orders");
          properties.put("topic.topic/priceUpdates", "priceUpdates");
          properties.put("topic.topic/spyTopic", "spyTopic");
@@ -78,7 +77,7 @@ public class DivertExample extends ActiveMQExample
          // Step 6. Create an initial context to perform the JNDI lookup on the New York server
          properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[1]);
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2);
          properties.put("topic.topic/newYorkPriceUpdates", "newYorkPriceUpdates");
          initialContextNewYork = new InitialContext(properties);
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/durable-subscription/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/durable-subscription/pom.xml b/examples/jms/durable-subscription/pom.xml
index 2b37eca..1d408de 100644
--- a/examples/jms/durable-subscription/pom.xml
+++ b/examples/jms/durable-subscription/pom.xml
@@ -57,17 +57,13 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <systemProperties>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -78,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.DurableSubscriptionExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -95,41 +85,7 @@ under the License.
                         <artifactId>artemis-jms-durable-subscription-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/embedded-simple/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/pom.xml b/examples/jms/embedded-simple/pom.xml
index 7762af3..9836ff6 100644
--- a/examples/jms/embedded-simple/pom.xml
+++ b/examples/jms/embedded-simple/pom.xml
@@ -73,16 +73,6 @@ under the License.
                         </goals>
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.EmbeddedExample</clientClass>
-                           <args>
-                              <param>tcp://localhost:61616</param>
-                              <param>tcp://localhost:61616</param>
-                           </args>
-                           <systemProperties>
-                              <property>
-                                 <name>exampleConfigDir</name>
-                                 <value>${basedir}/target/classes/activemq</value>
-                              </property>
-                           </systemProperties>
                         </configuration>
                      </execution>
                   </executions>
@@ -92,41 +82,7 @@ under the License.
                         <artifactId>artemis-jms-embedded-simple-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
index 8221873..c148dca 100644
--- a/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
+++ b/examples/jms/embedded-simple/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
@@ -16,10 +16,6 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.MessageConsumer;
@@ -27,13 +23,16 @@ import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
+import org.apache.activemq.artemis.api.jms.JMSFactoryType;
 import org.apache.activemq.artemis.common.example.ActiveMQExample;
 import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
-import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.artemis.jms.server.JMSServerManager;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
 import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManagerImpl;
-import org.apache.activemq.artemis.api.jms.JMSFactoryType;
 
 /**
  * This example demonstrates how to run an ActiveMQ Artemis embedded with JMS

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/embedded/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/embedded/pom.xml b/examples/jms/embedded/pom.xml
index f0eb3f9..e39c4a4 100644
--- a/examples/jms/embedded/pom.xml
+++ b/examples/jms/embedded/pom.xml
@@ -73,20 +73,6 @@ under the License.
                         </goals>
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.EmbeddedExample</clientClass>
-                           <args>
-                              <param>tcp://localhost:61616</param>
-                              <param>tcp://localhost:61617</param>
-                           </args>
-                           <systemProperties>
-                              <property>
-                                 <name>exampleConfigDir</name>
-                                 <value>${basedir}/target/classes/activemq</value>
-                              </property>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
                         </configuration>
                      </execution>
                   </executions>
@@ -96,36 +82,6 @@ under the License.
                         <artifactId>artemis-jms-embedded-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
                </plugin>
             </plugins>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java b/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
index 9300058..0c029ad 100644
--- a/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
+++ b/examples/jms/embedded/src/main/java/org/apache/activemq/artemis/jms/example/EmbeddedExample.java
@@ -16,9 +16,6 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import java.util.ArrayList;
-import java.util.Date;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.MessageConsumer;
@@ -26,6 +23,8 @@ import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
+import java.util.ArrayList;
+import java.util.Date;
 
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.common.example.ActiveMQExample;
@@ -55,7 +54,7 @@ public final class EmbeddedExample extends ActiveMQExample
    @Override
    public boolean runExample() throws Exception
    {
-            try
+      try
       {
 
          // Step 1. Create ActiveMQ Artemis core configuration, and set the properties accordingly

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/expiry/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/expiry/pom.xml b/examples/jms/expiry/pom.xml
index 16b081a..6133af4 100644
--- a/examples/jms/expiry/pom.xml
+++ b/examples/jms/expiry/pom.xml
@@ -57,17 +57,13 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <systemProperties>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -78,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.ExpiryExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -95,41 +85,7 @@ under the License.
                         <artifactId>artemis-jms-expiry-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/ha-policy-autobackup/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ha-policy-autobackup/pom.xml b/examples/jms/ha-policy-autobackup/pom.xml
index 1d3dc10..649adf0 100644
--- a/examples/jms/ha-policy-autobackup/pom.xml
+++ b/examples/jms/ha-policy-autobackup/pom.xml
@@ -57,34 +57,23 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start0</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                           <systemProperties>
-                              <property>
-                                 <name>udp-address</name>
-                                 <value>${udp-address}</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
-                        <id>start1</id>
+                        <id>create2</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
-                           <fork>true</fork>
-                           <systemProperties>
-                              <property>
-                                 <name>udp-address</name>
-                                 <value>${udp-address}</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server1</instance>
+                           <configuration>${basedir}/target/classes/activemq/server1</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -95,33 +84,9 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.HAPolicyAutoBackupExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
-                              <param>tcp://localhost:61617</param>
+                              <param>${basedir}/target/server0</param>
+                              <param>${basedir}/target/server1</param>
                            </args>
-                           <systemProperties>
-                              <property>
-                                 <name>exampleConfigDir</name>
-                                 <value>${basedir}/target/classes/activemq</value>
-                              </property>
-                           </systemProperties>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop0</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                        </configuration>
-                     </execution>
-                     <execution>
-                        <id>stop1</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                        <configuration>
-                           <configurationDir>${basedir}/target/classes/activemq/server1</configurationDir>
                         </configuration>
                      </execution>
                   </executions>
@@ -131,40 +96,7 @@ under the License.
                         <artifactId>ha-policy-autobackup</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java b/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java
index 4af82b4..10f858f 100644
--- a/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java
+++ b/examples/jms/ha-policy-autobackup/src/main/java/org/apache/activemq/artemis/jms/example/HAPolicyAutoBackupExample.java
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.artemis.jms.example;
 
-import java.util.Hashtable;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.MessageConsumer;
@@ -26,19 +24,18 @@ import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.TransportConfiguration;
 import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
 import org.apache.activemq.artemis.api.core.client.TopologyMember;
 import org.apache.activemq.artemis.common.example.ActiveMQExample;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
 /**
  * A simple example that demonstrates server side load-balancing of messages between the queue instances on different
  * nodes of the cluster.
@@ -46,7 +43,7 @@ import java.util.concurrent.TimeUnit;
  */
 public class HAPolicyAutoBackupExample extends ActiveMQExample
 {
-   public static void main(final String[] args)
+   public static void main(final String[] args) throws Exception
    {
       new HAPolicyAutoBackupExample().run(args);
    }
@@ -67,13 +64,13 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample
          // Step 1. Get an initial context for looking up JNDI from server 0 and 1
          Hashtable<String, Object> properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[0] + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
          properties.put("queue.queue/exampleQueue", "exampleQueue");
          ic0 = new InitialContext(properties);
 
          properties = new Hashtable<String, Object>();
          properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
-         properties.put("connectionFactory.ConnectionFactory", args[1] + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
+         properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2 + "?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1");
          ic1 = new InitialContext(properties);
 
          // Step 2. Look-up the JMS Queue object from JNDI
@@ -128,12 +125,13 @@ public class HAPolicyAutoBackupExample extends ActiveMQExample
             System.out.println("Got message: " + message0.getText() + " from node 0");
          }
 
-         // Step 14.now kill server1, messages will be scaled down to server0
-         killServer(1);
-
-         // Step 15.close the consumer so it doesnt get any messages
+         // Step 14.close the consumer so it doesnt get any messages
          consumer1.close();
 
+         // Step 15.now kill server1, messages will be scaled down to server0
+         killServer(1);
+         Thread.sleep(40000);
+
          // Step 16. we now receive the messages that were on server1 but were scaled down to server0
          for (int i = 0; i < numMessages / 2; i++)
          {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/broker.xml b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/broker.xml
index 79dd692..db98aa0 100644
--- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server0/broker.xml
@@ -29,13 +29,13 @@ under the License.
 
    <core xmlns="urn:activemq:core">
 
-      <bindings-directory>target/server0/data/messaging/bindings</bindings-directory>
+      <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
 
-      <journal-directory>target/server0/data/messaging/journal</journal-directory>
+      <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
 
-      <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory>
+      <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
 
-      <paging-directory>target/server0/data/messaging/paging</paging-directory>
+      <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
       <!-- Connectors -->
 
       <connectors>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/broker.xml b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/broker.xml
index 7b135ac..760ce0d 100644
--- a/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/ha-policy-autobackup/src/main/resources/activemq/server1/broker.xml
@@ -29,13 +29,13 @@ under the License.
 
    <core xmlns="urn:activemq:core">
 
-      <bindings-directory>target/server1/data/messaging/bindings</bindings-directory>
+      <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
 
-      <journal-directory>target/server1/data/messaging/journal</journal-directory>
+      <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
 
-      <large-messages-directory>target/server1/data/messaging/largemessages</large-messages-directory>
+      <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
 
-      <paging-directory>target/server1/data/messaging/paging</paging-directory>
+      <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
 
       <!-- Connectors -->
       <connectors>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/http-transport/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/http-transport/pom.xml b/examples/jms/http-transport/pom.xml
index a61bf1f..b13f800 100644
--- a/examples/jms/http-transport/pom.xml
+++ b/examples/jms/http-transport/pom.xml
@@ -57,17 +57,13 @@ under the License.
                   <artifactId>artemis-maven-plugin</artifactId>
                   <executions>
                      <execution>
-                        <id>start</id>
+                        <id>create</id>
                         <goals>
-                           <goal>start</goal>
+                           <goal>create</goal>
                         </goals>
                         <configuration>
-                           <systemProperties>
-                              <property>
-                                 <name>data.dir</name>
-                                 <value>${basedir}/target/</value>
-                              </property>
-                           </systemProperties>
+                           <instance>${basedir}/target/server0</instance>
+                           <configuration>${basedir}/target/classes/activemq/server0</configuration>
                         </configuration>
                      </execution>
                      <execution>
@@ -78,16 +74,10 @@ under the License.
                         <configuration>
                            <clientClass>org.apache.activemq.artemis.jms.example.HttpTransportExample</clientClass>
                            <args>
-                              <param>tcp://localhost:61616</param>
+                              <param>${basedir}/target/server0</param>
                            </args>
                         </configuration>
                      </execution>
-                     <execution>
-                        <id>stop</id>
-                        <goals>
-                           <goal>stop</goal>
-                        </goals>
-                     </execution>
                   </executions>
                   <dependencies>
                      <dependency>
@@ -95,47 +85,7 @@ under the License.
                         <artifactId>artemis-jms-http-transport-example</artifactId>
                         <version>${project.version}</version>
                      </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-core-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-client</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.activemq</groupId>
-                        <artifactId>artemis-jms-server</artifactId>
-                        <version>${project.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>io.netty</groupId>
-                        <artifactId>netty-all</artifactId>
-                        <version>${netty.version}</version>
-                     </dependency>
-                     <dependency>
-                        <groupId>org.apache.geronimo.specs</groupId>
-                        <artifactId>geronimo-jms_2.0_spec</artifactId>
-                        <version>${geronimo.jms.2.spec.version}</version>
-                     </dependency>
                   </dependencies>
-                  <configuration>
-                     <waitOnStart>false</waitOnStart>
-                     <configurationDir>${basedir}/target/classes/activemq/server0</configurationDir>
-                     <systemProperties>
-                        <property>
-                           <name>data.dir</name>
-                           <value>${basedir}/target/</value>
-                        </property>
-                     </systemProperties>
-                  </configuration>
                </plugin>
             </plugins>
          </build>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/b3af4bb7/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml b/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml
index 40cf947..f6062b6 100644
--- a/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/http-transport/src/main/resources/activemq/server0/broker.xml
@@ -41,6 +41,8 @@ under the License.
 
       <acceptors>
          <acceptor name="netty-acceptor">tcp://localhost:8080</acceptor>
+         <!-- This is being defined just so the check-alive on the ArtemisExample super class works -->
+         <acceptor name="netty-accepto-checkalive">tcp://localhost:61616</acceptor>
       </acceptors>
 
       <!-- Other config -->


Mime
View raw message