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 2015/07/29 23:22:18 UTC
[12/24] activemq-artemis git commit: Continuing work on ARTEMIS-178
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java b/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java
index ca916ee..fcd3cca 100644
--- a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java
+++ b/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java
@@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.jms.example;
+import org.apache.activemq.artemis.util.ServerUtil;
+
import java.lang.Object;
import java.lang.String;
import java.util.Hashtable;
@@ -32,37 +34,37 @@ import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
+import javax.naming.NamingException;
/**
* A simple example that demonstrates application-layer failover of the JMS connection from one node to another
* when the live server crashes
*/
-public class ApplicationLayerFailoverExample extends ActiveMQExample
+public class ApplicationLayerFailoverExample
{
- public static void main(final String[] args)
- {
- new ApplicationLayerFailoverExample().run(args);
- }
+ private static InitialContext initialContext;
- private volatile InitialContext initialContext;
+ private static Connection connection;
- private volatile Connection connection;
+ private static Session session;
- private volatile Session session;
+ private static MessageConsumer consumer;
- private volatile MessageConsumer consumer;
+ private static MessageProducer producer;
- private volatile MessageProducer producer;
+ private static final CountDownLatch failoverLatch = new CountDownLatch(1);
- private final CountDownLatch failoverLatch = new CountDownLatch(1);
+ private static Process server0;
- @Override
- public boolean runExample() throws Exception
+ private static Process server1;
+
+ public static void main(final String[] args) throws Exception
{
try
{
+ server0 = ServerUtil.startServer(args[0], ApplicationLayerFailoverExample.class.getSimpleName() + "0", 0, 5000);
+ server1 = ServerUtil.startServer(args[1], ApplicationLayerFailoverExample.class.getSimpleName() + "1", 1, 5000);
+
// Step 1. We create our JMS Connection, Session, MessageProducer and MessageConsumer on server 1.
createJMSObjects(0);
@@ -99,21 +101,12 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample
System.out.println("Killing the server");
- killServer(0);
-
- // this utility method will wait for the server1 to be activated
- waitForServerStart(1, 20000);
-
+ ServerUtil.killServer(server0);
// Step 6. Wait for the client side to register the failure and reconnect
boolean ok = failoverLatch.await(5000, TimeUnit.MILLISECONDS);
- if (!ok)
- {
- return false;
- }
-
System.out.println("Reconnection has occurred. Now sending more messages.");
// Step 8. We now send some more messages
@@ -135,23 +128,21 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample
System.out.println("Got message: " + message0.getText());
}
-
- return true;
}
catch(Throwable t)
{
t.printStackTrace();
- return false;
}
finally
{
// Step 14. Be sure to close our resources!
-
closeResources();
+ ServerUtil.killServer(server0);
+ ServerUtil.killServer(server1);
}
}
- private void createJMSObjects(final int server) throws Exception
+ private static void createJMSObjects(final int server) throws Exception
{
// Step 1. Get an initial context for looking up JNDI from the server
Hashtable<String, Object> properties = new Hashtable<String, Object>();
@@ -182,20 +173,34 @@ public class ApplicationLayerFailoverExample extends ActiveMQExample
producer = session.createProducer(queue);
}
- private void closeResources() throws Exception
+ private static void closeResources()
{
if (initialContext != null)
{
- initialContext.close();
+ try
+ {
+ initialContext.close();
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
}
if (connection != null)
{
- connection.close();
+ try
+ {
+ connection.close();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
}
}
- private class ExampleListener implements ExceptionListener
+ private static class ExampleListener implements ExceptionListener
{
public void onException(final JMSException exception)
{
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/bridge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/bridge/pom.xml b/examples/jms/bridge/pom.xml
index f1dd547..73cbdc5 100644
--- a/examples/jms/bridge/pom.xml
+++ b/examples/jms/bridge/pom.xml
@@ -27,9 +27,9 @@ under the License.
<version>1.0.1-SNAPSHOT</version>
</parent>
- <artifactId>artemis-jms-bridge-example</artifactId>
+ <artifactId>artemis-jms-core-bridge-example</artifactId>
<packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Bridge Example</name>
+ <name>ActiveMQ Artemis Core Bridge Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../..</activemq.basedir>
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
<version>${project.version}</version>
@@ -62,7 +57,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -72,7 +67,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
@@ -83,15 +78,65 @@ under the License.
</configuration>
</execution>
<execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
+ </configuration>
+ </execution>
+ <execution>
<id>runClient</id>
<goals>
- <goal>client</goal>
+ <goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.BridgeExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
@@ -99,29 +144,9 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>artemis-jms-bridge-example</artifactId>
+ <artifactId>artemis-jms-core-bridge-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-jms-client</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/54d0d2b4/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java b/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
index 4346c32..a4a165c 100644
--- a/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
+++ b/examples/jms/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
@@ -26,21 +26,13 @@ import javax.jms.Session;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* This example demonstrates a core bridge set-up between two nodes, consuming messages from a queue
* on one node and forwarding them to an address on the second node.
*/
-public class BridgeExample extends ActiveMQExample
+public class BridgeExample
{
- public static void main(final String[] args)
- {
- new BridgeExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection0 = null;
@@ -120,9 +112,9 @@ public class BridgeExample extends ActiveMQExample
producer.send(message);
System.out.println("Sent " + message.getStringProperty("name") +
- " message with " +
- message.getStringProperty("hat") +
- " hat to sausage-factory on node 0");
+ " message with " +
+ message.getStringProperty("hat") +
+ " hat to sausage-factory on node 0");
// Step 14 - we successfully receive the aardvark message from the mincing-machine one node 1. The aardvark's
// hat is now blue since it has been transformed!
@@ -130,9 +122,9 @@ public class BridgeExample extends ActiveMQExample
Message receivedMessage = consumer.receive(5000);
System.out.println("Received " + receivedMessage.getStringProperty("name") +
- " message with " +
- receivedMessage.getStringProperty("hat") +
- " hat from mincing-machine on node 1");
+ " message with " +
+ receivedMessage.getStringProperty("hat") +
+ " hat from mincing-machine on node 1");
// Step 13. We create and send another message, this time representing a sasquatch with a mauve hat to the
// sausage-factory on node 0. This won't be bridged to the mincing-machine since we only want aardvarks, not
@@ -147,9 +139,9 @@ public class BridgeExample extends ActiveMQExample
producer.send(message);
System.out.println("Sent " + message.getStringProperty("name") +
- " message with " +
- message.getStringProperty("hat") +
- " hat to sausage-factory on node 0");
+ " message with " +
+ message.getStringProperty("hat") +
+ " hat to sausage-factory on node 0");
// Step 14. We don't receive the message since it has not been bridged.
@@ -161,10 +153,8 @@ public class BridgeExample extends ActiveMQExample
}
else
{
- return false;
+ throw new IllegalStateException();
}
-
- return true;
}
finally
{
@@ -191,5 +181,4 @@ public class BridgeExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/browser/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/browser/pom.xml b/examples/jms/browser/pom.xml
index 530f66b..adaf222 100644
--- a/examples/jms/browser/pom.xml
+++ b/examples/jms/browser/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -64,14 +59,35 @@ under the License.
</goals>
</execution>
<execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
<id>runClient</id>
<goals>
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.QueueBrowserExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java b/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
index 8e8e422..6c93cc6 100644
--- a/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
+++ b/examples/jms/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
@@ -27,20 +27,12 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import java.util.Enumeration;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example which shows how to use a QueueBrowser to look at messages of a queue without removing them from the queue
*/
-public class QueueBrowserExample extends ActiveMQExample
+public class QueueBrowserExample
{
- public static void main(final String[] args)
- {
- new QueueBrowserExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection = null;
InitialContext initialContext = null;
@@ -98,9 +90,6 @@ public class QueueBrowserExample extends ActiveMQExample
System.out.println("Received message: " + messageReceived.getText());
messageReceived = (TextMessage)messageConsumer.receive(5000);
System.out.println("Received message: " + messageReceived.getText());
-
- return true;
-
}
finally
{
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-kickoff/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-kickoff/pom.xml b/examples/jms/client-kickoff/pom.xml
index 22d511c..1c86b5a 100644
--- a/examples/jms/client-kickoff/pom.xml
+++ b/examples/jms/client-kickoff/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId>
<version>${project.version}</version>
@@ -72,14 +67,35 @@ under the License.
</configuration>
</execution>
<execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
<id>runClient</id>
<goals>
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClientKickoffExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
<args>
- <param>${basedir}/target/server0</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java b/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
index eb5db60..5421739 100644
--- a/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
+++ b/examples/jms/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
@@ -27,27 +27,21 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.InitialContext;
+import java.lang.Exception;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
/**
* An example that shows how to kick off a client connected to ActiveMQ Artemis by using JMX.
*/
-public class ClientKickoffExample extends ActiveMQExample
+public class ClientKickoffExample
{
private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi";
- public static void main(final String[] args)
- {
- new ClientKickoffExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
QueueConnection connection = null;
InitialContext initialContext = null;
@@ -67,7 +61,7 @@ public class ClientKickoffExample extends ActiveMQExample
connection.setExceptionListener(new ExceptionListener()
{
@Override
- public void onException(final JMSException e)
+ public void onException(final JMSException e)
{
exception.set(e);
}
@@ -81,9 +75,9 @@ public class ClientKickoffExample extends ActiveMQExample
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap<String, String>());
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
ActiveMQServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(mbsc,
- on,
- ActiveMQServerControl.class,
- false);
+ on,
+ ActiveMQServerControl.class,
+ false);
// Step 7. List the remote address connected to the server
System.out.println("List of remote addresses connected to the server:");
@@ -107,8 +101,6 @@ public class ClientKickoffExample extends ActiveMQExample
System.err.println("----------------------------------");
exception.get().printStackTrace();
System.err.println("----------------------------------");
-
- return true;
}
finally
{
@@ -123,5 +115,4 @@ public class ClientKickoffExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml b/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml
index af12f6a..3b5a465 100644
--- a/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/client-kickoff/src/main/resources/activemq/server0/broker.xml
@@ -27,13 +27,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:../data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:../data}/paging</paging-directory>
<!-- true to expose ActiveMQ Artemis resources through JMX -->
<jmx-management-enabled>true</jmx-management-enabled>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-side-failoverlistener/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-failoverlistener/pom.xml b/examples/jms/client-side-failoverlistener/pom.xml
index 87c41f3..cfdcdd6 100644
--- a/examples/jms/client-side-failoverlistener/pom.xml
+++ b/examples/jms/client-side-failoverlistener/pom.xml
@@ -37,8 +37,13 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -57,31 +62,31 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server0</instance>
- <data>../../shared/</data>
+ <dataFolder>../shared</dataFolder>
<sharedStore>true</sharedStore>
<slave>false</slave>
+ <failoverOnShutdown>true</failoverOnShutdown>
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server1</instance>
- <data>../../shared/</data>
+ <dataFolder>../shared</dataFolder>
<sharedStore>true</sharedStore>
<slave>true</slave>
<portOffset>1</portOffset>
</configuration>
</execution>
-
<execution>
<id>runClient</id>
<goals>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java b/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java
index c753000..0066139 100644
--- a/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java
+++ b/examples/jms/client-side-failoverlistener/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideFailoverListerExample.java
@@ -16,6 +16,11 @@
*/
package org.apache.activemq.artemis.jms.example;
+import org.apache.activemq.artemis.api.core.client.FailoverEventListener;
+import org.apache.activemq.artemis.api.core.client.FailoverEventType;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
+import org.apache.activemq.artemis.util.ServerUtil;
+
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
@@ -25,38 +30,19 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.api.core.client.FailoverEventListener;
-import org.apache.activemq.artemis.api.core.client.FailoverEventType;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
-
/**
* This example demonstrates how you can listen on failover event on the client side
- *
+ * <p/>
* In this example there are two nodes running in a cluster, both server will be running for start,
* but after a while the first server will crash. This will trigger a fail-over event
*/
-public class ClientSideFailoverListerExample extends ActiveMQExample
+public class ClientSideFailoverListerExample
{
- public static void main(final String[] args) throws Exception
- {
- new ClientSideFailoverListerExample().run(args);
- }
-
- @Override
- protected void startServers(String[] serversArgs) throws Exception
- {
- startServer(0, 5000);
-
- // server 1 is a backup, it's not activated
- startServer(1, 0);
-
- Thread.sleep(1000);
- }
+ private static Process server0;
+ private static Process server1;
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
InitialContext initialContext = null;
@@ -64,20 +50,23 @@ public class ClientSideFailoverListerExample extends ActiveMQExample
try
{
+ server0 = ServerUtil.startServer(args[0], ClientSideFailoverListerExample.class.getSimpleName() + "0", 0, 5000);
+ server1 = ServerUtil.startServer(args[1], ClientSideFailoverListerExample.class.getSimpleName() + "1", 1, 0);
+
// Step 1. Get an initial context for looking up JNDI from server 0
initialContext = new InitialContext();
// Step 2. Look-up the JMS Queue object from JNDI
- Queue queue = (Queue)initialContext.lookup("queue/exampleQueue");
+ Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
// Step 3. Look-up a JMS Connection Factory object from JNDI on server 0
- ConnectionFactory connectionFactory = (ConnectionFactory)initialContext.lookup("ConnectionFactory");
+ ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
// Step 4. We create 1 JMS connections from the same connection factory.
// Wait a little while to make sure broadcasts from all nodes have reached the client
Thread.sleep(5000);
connectionA = connectionFactory.createConnection();
- ((ActiveMQConnection)connectionA).setFailoverListener(new FailoverListenerImpl());
+ ((ActiveMQConnection) connectionA).setFailoverListener(new FailoverListenerImpl());
// Step 5. We create JMS Sessions
Session sessionA = connectionA.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -102,8 +91,6 @@ public class ClientSideFailoverListerExample extends ActiveMQExample
// Step 9. We consume messages from the session A, one at a time.
// We reached message no 5 the first server will crash
consume(sessionA, queue, numMessages, "A");
-
- return true;
}
finally
{
@@ -118,20 +105,23 @@ public class ClientSideFailoverListerExample extends ActiveMQExample
{
initialContext.close();
}
+
+ ServerUtil.killServer(server0);
+ ServerUtil.killServer(server1);
}
}
- private void consume(Session session, Queue queue, int numMessages, String node) throws Exception
+ private static void consume(Session session, Queue queue, int numMessages, String node) throws Exception
{
MessageConsumer consumer = session.createConsumer(queue);
for (int i = 0; i < numMessages; i++)
{
- TextMessage message = (TextMessage)consumer.receive(2000);
+ TextMessage message = (TextMessage) consumer.receive(2000);
System.out.println("Got message: " + message.getText() + " from node " + node);
if (i == 5)
{
- killServer(0);
+ ServerUtil.killServer(server0);
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-side-load-balancing/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-load-balancing/pom.xml b/examples/jms/client-side-load-balancing/pom.xml
index fc4ec4c..77c8186 100644
--- a/examples/jms/client-side-load-balancing/pom.xml
+++ b/examples/jms/client-side-load-balancing/pom.xml
@@ -37,8 +37,8 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -57,41 +57,82 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server0</instance>
<clustered>true</clustered>
- <configuration>${basedir}/target/classes/activemq/server0</configuration>
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server1</instance>
<clustered>true</clustered>
- <configuration>${basedir}/target/classes/activemq/server1</configuration>
<portOffset>1</portOffset>
</configuration>
</execution>
<execution>
- <id>create3</id>
+ <id>create2</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server2</instance>
<clustered>true</clustered>
- <configuration>${basedir}/target/classes/activemq/server2</configuration>
<portOffset>2</portOffset>
</configuration>
</execution>
-
+ <execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start2</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server2</location>
+ <testURI>tcp://localhost:61618</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server2</name>
+ </configuration>
+ </execution>
<execution>
<id>runClient</id>
<goals>
@@ -99,10 +140,41 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClientSideLoadBalancingExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop2</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server2</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
- <param>${basedir}/target/server2</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java b/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java
index 287b2a7..688ba5a 100644
--- a/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java
+++ b/examples/jms/client-side-load-balancing/src/main/java/org/apache/activemq/artemis/jms/example/ClientSideLoadBalancingExample.java
@@ -26,8 +26,6 @@ import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* This example demonstrates how sessions created from a single connection can be load
* balanced across the different nodes of the cluster.
@@ -35,15 +33,9 @@ import org.apache.activemq.artemis.common.example.ActiveMQExample;
* In this example there are three nodes and we use a round-robin client side load-balancing
* policy.
*/
-public class ClientSideLoadBalancingExample extends ActiveMQExample
+public class ClientSideLoadBalancingExample
{
- public static void main(final String[] args)
- {
- new ClientSideLoadBalancingExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
InitialContext initialContext = null;
@@ -116,8 +108,6 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample
consume(sessionA, queue, numMessages, "A");
consume(sessionB, queue, numMessages, "B");
consume(sessionC, queue, numMessages, "C");
-
- return true;
}
finally
{
@@ -143,7 +133,7 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample
}
}
- private void consume(Session session, Queue queue, int numMessages, String node) throws JMSException
+ private static void consume(Session session, Queue queue, int numMessages, String node) throws JMSException
{
MessageConsumer consumer = session.createConsumer(queue);
@@ -154,6 +144,5 @@ public class ClientSideLoadBalancingExample extends ActiveMQExample
}
System.out.println("receive other message from node " + node + ": " + consumer.receive(2000));
-
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-durable-subscription/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/pom.xml b/examples/jms/clustered-durable-subscription/pom.xml
index a23512c..041fbe3 100644
--- a/examples/jms/clustered-durable-subscription/pom.xml
+++ b/examples/jms/clustered-durable-subscription/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -57,7 +52,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -67,7 +62,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
@@ -78,15 +73,65 @@ under the License.
</configuration>
</execution>
<execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
+ </configuration>
+ </execution>
+ <execution>
<id>runClient</id>
<goals>
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClusteredDurableSubscriptionExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java b/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java
index d850f08..31d1434 100644
--- a/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java
+++ b/examples/jms/clustered-durable-subscription/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredDurableSubscriptionExample.java
@@ -26,23 +26,15 @@ import javax.jms.Topic;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that shows a JMS Durable Subscription across two nodes of a cluster.
*
* The same durable subscription can exist on more than one node of the cluster, and messages
* sent to the topic will be load-balanced in a round-robin fashion between the two nodes
*/
-public class ClusteredDurableSubscriptionExample extends ActiveMQExample
+public class ClusteredDurableSubscriptionExample
{
- public static void main(final String[] args)
- {
- new ClusteredDurableSubscriptionExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection0 = null;
@@ -145,8 +137,6 @@ public class ClusteredDurableSubscriptionExample extends ActiveMQExample
System.out.println("Got message: " + message1.getText() + " from node 1");
}
-
- return true;
}
finally
{
@@ -172,5 +162,4 @@ public class ClusteredDurableSubscriptionExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml
index f9b0e67..6214a63 100644
--- a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server0/broker.xml
@@ -29,13 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml
index 64f6d68..3d1cb2e 100644
--- a/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/clustered-durable-subscription/src/main/resources/activemq/server1/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir}/server1/data/messaging/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir}/server1/data/messaging/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir}/server1/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir}/server1/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
<connectors>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-grouping/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/pom.xml b/examples/jms/clustered-grouping/pom.xml
index a9357cf..0f9f101 100644
--- a/examples/jms/clustered-grouping/pom.xml
+++ b/examples/jms/clustered-grouping/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -57,7 +52,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -67,25 +62,68 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server1</instance>
<configuration>${basedir}/target/classes/activemq/server1</configuration>
- <portOffset>1</portOffset>
</configuration>
</execution>
<execution>
- <id>create3</id>
+ <id>create2</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server2</instance>
<configuration>${basedir}/target/classes/activemq/server2</configuration>
- <portOffset>2</portOffset>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start2</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server2</location>
+ <testURI>tcp://localhost:61618</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server2</name>
</configuration>
</execution>
<execution>
@@ -95,10 +133,41 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClusteredGroupingExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop2</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server2</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
- <param>${basedir}/target/server2</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java b/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java
index b13681b..a60ea6b 100644
--- a/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java
+++ b/examples/jms/clustered-grouping/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredGroupingExample.java
@@ -26,21 +26,13 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that demonstrates server side load-balancing of messages between the queue instances on different
* nodes of the cluster.
*/
-public class ClusteredGroupingExample extends ActiveMQExample
+public class ClusteredGroupingExample
{
- public static void main(String[] args)
- {
- new ClusteredGroupingExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(String[] args) throws Exception
{
Connection connection0 = null;
@@ -171,8 +163,6 @@ public class ClusteredGroupingExample extends ActiveMQExample
System.out.println("Got message: " + message0.getText() + " from node 0");
}
-
- return true;
}
finally
{
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml
index 8b67aa5..77fa2e6 100644
--- a/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server0/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir:../data}/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml
index 7ab2e7e..fabd98d 100644
--- a/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server1/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir:../data}/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml
index 1776c5c..07d18fc 100644
--- a/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml
+++ b/examples/jms/clustered-grouping/src/main/resources/activemq/server2/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>${data.dir:../data}/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-jgroups/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/pom.xml b/examples/jms/clustered-jgroups/pom.xml
index b19deb3..fc90be7 100644
--- a/examples/jms/clustered-jgroups/pom.xml
+++ b/examples/jms/clustered-jgroups/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -71,7 +66,7 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
@@ -82,7 +77,36 @@ under the License.
</libList>
<instance>${basedir}/target/server1</instance>
<configuration>${basedir}/target/classes/activemq/server1</configuration>
- <portOffset>1</portOffset>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
</configuration>
</execution>
<execution>
@@ -92,9 +116,29 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClusteredJgroupsExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java b/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java
index 9d7c3dc..5321618 100644
--- a/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java
+++ b/examples/jms/clustered-jgroups/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredJgroupsExample.java
@@ -26,20 +26,12 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that demonstrates clustering using jgroups.
*/
-public class ClusteredJgroupsExample extends ActiveMQExample
+public class ClusteredJgroupsExample
{
- public static void main(final String[] args)
- {
- new ClusteredJgroupsExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection0 = null;
@@ -128,8 +120,6 @@ public class ClusteredJgroupsExample extends ActiveMQExample
System.out.println("Got message: " + message1.getText() + " from node 1");
}
-
- return true;
}
finally
{
@@ -156,5 +146,4 @@ public class ClusteredJgroupsExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml
index 8eb8284..4af9867 100644
--- a/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/clustered-jgroups/src/main/resources/activemq/server0/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <paging-directory>server0/paging</paging-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <bindings-directory>server0/bindings</bindings-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <journal-directory>server0/journal</journal-directory>
-
- <large-messages-directory>server0/large-messages</large-messages-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml
index b72e119..3393a42 100644
--- a/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml
+++ b/examples/jms/clustered-jgroups/src/main/resources/activemq/server1/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <paging-directory>server1/paging</paging-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <bindings-directory>server1/bindings</bindings-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <journal-directory>server1/journal</journal-directory>
-
- <large-messages-directory>server1/large-messages</large-messages-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
<connectors>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/pom.xml b/examples/jms/clustered-queue/pom.xml
index d4afa59..7b42875 100644
--- a/examples/jms/clustered-queue/pom.xml
+++ b/examples/jms/clustered-queue/pom.xml
@@ -37,11 +37,6 @@ under the License.
<dependencies>
<dependency>
- <groupId>org.apache.activemq.examples.jms</groupId>
- <artifactId>common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_2.0_spec</artifactId>
</dependency>
@@ -57,7 +52,7 @@ under the License.
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
- <id>create</id>
+ <id>create0</id>
<goals>
<goal>create</goal>
</goals>
@@ -67,14 +62,43 @@ under the License.
</configuration>
</execution>
<execution>
- <id>create2</id>
+ <id>create1</id>
<goals>
<goal>create</goal>
</goals>
<configuration>
<instance>${basedir}/target/server1</instance>
<configuration>${basedir}/target/classes/activemq/server1</configuration>
- <portOffset>1</portOffset>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server0</location>
+ <testURI>tcp://localhost:61616</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server0</name>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <location>${basedir}/target/server1</location>
+ <testURI>tcp://localhost:61617</testURI>
+ <args>
+ <param>run</param>
+ </args>
+ <name>server1</name>
</configuration>
</execution>
<execution>
@@ -84,9 +108,29 @@ under the License.
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClusteredQueueExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop0</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server0</location>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop1</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <location>${basedir}/target/server1</location>
<args>
- <param>${basedir}/target/server0</param>
- <param>${basedir}/target/server1</param>
+ <param>stop</param>
</args>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java b/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java
index 0011865..12a0a45 100644
--- a/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java
+++ b/examples/jms/clustered-queue/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredQueueExample.java
@@ -26,21 +26,13 @@ import javax.jms.TextMessage;
import javax.naming.InitialContext;
import java.util.Hashtable;
-import org.apache.activemq.artemis.common.example.ActiveMQExample;
-
/**
* A simple example that demonstrates server side load-balancing of messages between the queue instances on different
* nodes of the cluster.
*/
-public class ClusteredQueueExample extends ActiveMQExample
+public class ClusteredQueueExample
{
- public static void main(final String[] args)
- {
- new ClusteredQueueExample().run(args);
- }
-
- @Override
- public boolean runExample() throws Exception
+ public static void main(final String[] args) throws Exception
{
Connection connection0 = null;
@@ -55,7 +47,7 @@ public class ClusteredQueueExample extends ActiveMQExample
// Step 1. Get an initial context for looking up JNDI from server 0
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP1);
+ properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616");
properties.put("queue.queue/exampleQueue", "exampleQueue");
ic0 = new InitialContext(properties);
@@ -68,7 +60,7 @@ public class ClusteredQueueExample extends ActiveMQExample
// Step 4. Get an initial context for looking up JNDI from server 1
properties = new Hashtable<String, Object>();
properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", DEFAULT_TCP2);
+ properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617");
ic1 = new InitialContext(properties);
// Step 5. Look-up a JMS Connection Factory object from JNDI on server 1
@@ -129,8 +121,6 @@ public class ClusteredQueueExample extends ActiveMQExample
System.out.println("Got message: " + message1.getText() + " from node 1");
}
-
- return true;
}
finally
{
@@ -157,5 +147,4 @@ public class ClusteredQueueExample extends ActiveMQExample
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-roles.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/artemis-users.properties
+++ /dev/null
@@ -1,17 +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.
-## ---------------------------------------------------------------------------
-guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/54d0d2b4/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml
index f038cfe..db97076 100644
--- a/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml
+++ b/examples/jms/clustered-queue/src/main/resources/activemq/server0/broker.xml
@@ -29,14 +29,13 @@ under the License.
<core xmlns="urn:activemq:core">
+ <bindings-directory>${data.dir:./data}/bindings</bindings-directory>
- <bindings-directory>target/server0/data/messaging/bindings</bindings-directory>
+ <journal-directory>${data.dir:./data}/journal</journal-directory>
- <journal-directory>target/server0/data/messaging/journal</journal-directory>
+ <large-messages-directory>${data.dir:./data}/largemessages</large-messages-directory>
- <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>target/server0/data/messaging/paging</paging-directory>
+ <paging-directory>${data.dir:./data}/paging</paging-directory>
<!-- Connectors -->
<connectors>