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/08/12 19:05:13 UTC
[1/4] activemq-artemis git commit: adding new OpenWire examples
Repository: activemq-artemis
Updated Branches:
refs/heads/master 1f0ea1ce2 -> f369142e2
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-listener/readme.html
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-listener/readme.html b/examples/protocols/openwire/message-listener/readme.html
new file mode 100644
index 0000000..e46e834
--- /dev/null
+++ b/examples/protocols/openwire/message-listener/readme.html
@@ -0,0 +1,35 @@
+<!--
+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.
+-->
+
+<html>
+ <head>
+ <title>ActiveMQ Artemis JMS Queue Example</title>
+ <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
+ <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
+ <script type="text/javascript" src="../../../common/prettify.js"></script>
+ </head>
+ <body onload="prettyPrint()">
+ <h1>JMS Queue Message Listener for openwire</h1>
+
+ <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
+
+ <p>This example shows how to use a MessageListener with the openwire client</p>
+
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
new file mode 100644
index 0000000..59f1809
--- /dev/null
+++ b/examples/protocols/openwire/message-listener/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
@@ -0,0 +1,103 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
+ */
+public class QueueExample {
+
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ try {
+
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
+
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue("exampleQueue");
+
+ int nMessages = 1000;
+
+ CountDownLatch latch = new CountDownLatch(nMessages);
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ messageConsumer.setMessageListener(new LocalListener(latch));
+
+ connection.start();
+
+ MessageProducer producer = session.createProducer(queue);
+
+ for (int i = 0; i < 1000; i++) {
+ TextMessage message = session.createTextMessage("This is a text message " + i);
+
+ System.out.println("Sent message: " + message.getText());
+
+ producer.send(message);
+ }
+
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new RuntimeException("listener didn't receive all the messages");
+ }
+
+ System.out.println("Finished ok!");
+
+
+ }
+ finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+
+ private static class LocalListener implements MessageListener {
+
+ CountDownLatch latch;
+
+ LocalListener(CountDownLatch latch) {
+ this.latch = latch;
+ }
+
+ @Override
+ public void onMessage(Message message) {
+ latch.countDown();
+ try {
+ System.out.println("Received " + ((TextMessage)message).getText());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-recovery/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-recovery/pom.xml b/examples/protocols/openwire/message-recovery/pom.xml
new file mode 100644
index 0000000..5caa161
--- /dev/null
+++ b/examples/protocols/openwire/message-recovery/pom.xml
@@ -0,0 +1,102 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>openwire-examples</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>message-recovery</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Queue Example for openwire</name>
+
+ <properties>
+ <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-client</artifactId>
+ <version>${activemq5-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>${slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <!-- this is to have the ServerUtil -->
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ </configuration>
+ </execution>
+ <execution>
+ <id>runClient</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.example.QueueExample</clientClass>
+ <args>
+ <param>${basedir}/target/server0</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>message-recovery</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-recovery/readme.html
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-recovery/readme.html b/examples/protocols/openwire/message-recovery/readme.html
new file mode 100644
index 0000000..2bb884f
--- /dev/null
+++ b/examples/protocols/openwire/message-recovery/readme.html
@@ -0,0 +1,35 @@
+<!--
+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.
+-->
+
+<html>
+ <head>
+ <title>ActiveMQ Artemis JMS Queue Example</title>
+ <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
+ <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
+ <script type="text/javascript" src="../../../common/prettify.js"></script>
+ </head>
+ <body onload="prettyPrint()">
+ <h1>JMS Queue Message Listener for openwire</h1>
+
+ <pre>This example will start and stop the server within the example.</pre>
+
+ <p>This example shows how to use send messages to a queue, and having these messages recovered from the journal.</p>
+
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
new file mode 100644
index 0000000..0ce9c94
--- /dev/null
+++ b/examples/protocols/openwire/message-recovery/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
@@ -0,0 +1,119 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.util.ServerUtil;
+
+/**
+ * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
+ */
+public class QueueExample {
+
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ Process server0 = null;
+ try {
+ server0 = ServerUtil.startServer(args[0], QueueExample.class.getSimpleName() + "0", 0, 5000);
+
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
+
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue("exampleQueue");
+
+ MessageProducer producer = session.createProducer(queue);
+
+ int nMessages = 1000;
+
+ for (int i = 0; i < nMessages; i++) {
+ TextMessage message = session.createTextMessage("This is a text message " + i);
+
+ System.out.println("Sent message: " + message.getText());
+
+ producer.send(message);
+ }
+
+ connection.close();
+
+ ServerUtil.killServer(server0);
+
+ server0 = ServerUtil.startServer(args[0], QueueExample.class.getSimpleName() + "0", 0, 5000);
+
+ ServerUtil.waitForServerToStart(0, 5000);
+
+ connection = cf.createConnection();
+
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ CountDownLatch latch = new CountDownLatch(nMessages);
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ messageConsumer.setMessageListener(new LocalListener(latch));
+
+ connection.start();
+
+
+ if (!latch.await(5, TimeUnit.SECONDS)) {
+ throw new RuntimeException("listener didn't receive all the messages");
+ }
+
+ System.out.println("Finished ok!");
+ }
+ finally {
+ if (connection != null) {
+ connection.close();
+ }
+
+ ServerUtil.killServer(server0);
+ }
+ }
+
+ private static class LocalListener implements MessageListener {
+
+ CountDownLatch latch;
+
+ LocalListener(CountDownLatch latch) {
+ this.latch = latch;
+ }
+
+ @Override
+ public void onMessage(Message message) {
+ latch.countDown();
+ try {
+ System.out.println("Received " + ((TextMessage)message).getText());
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/pom.xml b/examples/protocols/openwire/pom.xml
index e7e9338..cc5eb76 100644
--- a/examples/protocols/openwire/pom.xml
+++ b/examples/protocols/openwire/pom.xml
@@ -43,6 +43,9 @@ under the License.
<id>release</id>
<modules>
<module>chat</module>
+ <module>queue</module>
+ <module>message-listener</module>
+ <module>message-recovery</module>
</modules>
</profile>
<profile>
@@ -50,6 +53,10 @@ under the License.
<modules>
<!-- Needs to be done manually
<module>chat</module> -->
+
+ <module>queue</module>
+ <module>message-listener</module>
+ <module>message-recovery</module>
</modules>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/queue/pom.xml b/examples/protocols/openwire/queue/pom.xml
new file mode 100644
index 0000000..204b67a
--- /dev/null
+++ b/examples/protocols/openwire/queue/pom.xml
@@ -0,0 +1,119 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>openwire-examples</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>queue-openwire</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Queue Example for openwire</name>
+
+ <properties>
+ <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-client</artifactId>
+ <version>${activemq5-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>${slf4j-version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ </configuration>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <ignore>${noServer}</ignore>
+ <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.QueueExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>queue-openwire</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/queue/readme.html
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/queue/readme.html b/examples/protocols/openwire/queue/readme.html
new file mode 100644
index 0000000..948977f
--- /dev/null
+++ b/examples/protocols/openwire/queue/readme.html
@@ -0,0 +1,39 @@
+<!--
+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.
+-->
+
+<html>
+ <head>
+ <title>ActiveMQ Artemis JMS Queue Example</title>
+ <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
+ <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
+ <script type="text/javascript" src="../../../common/prettify.js"></script>
+ </head>
+ <body onload="prettyPrint()">
+ <h1>JMS Queue Example for open wire</h1>
+
+ <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
+
+
+ <p>This example shows you how to send and receive a message to a JMS Queue using ActiveMQ Artemis.</p>
+ <p>This example does exactly the same as the <a href="../../../broker-features/standard/queue/readme.html">queue example under broker-features/standard</a>, however using the openwire client.</p>
+ <p>Queues are a standard part of JMS, please consult the JMS 1.1 specification for full details.</p>
+ <p>A Queue is used to send messages point to point, from a producer to a consumer. The queue guarantees message ordering between these 2 points.</p>
+ <p>Notice this example is using pretty much a default stock configuration</p>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java b/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
new file mode 100644
index 0000000..ca3f510
--- /dev/null
+++ b/examples/protocols/openwire/queue/src/main/java/org/apache/activemq/artemis/jms/example/QueueExample.java
@@ -0,0 +1,68 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+
+/**
+ * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
+ */
+public class QueueExample {
+
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ try {
+
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
+
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue queue = session.createQueue("exampleQueue");
+
+ MessageProducer producer = session.createProducer(queue);
+
+ TextMessage message = session.createTextMessage("This is a text message");
+
+ System.out.println("Sent message: " + message.getText());
+
+ producer.send(message);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ connection.start();
+
+ TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("Received message: " + messageReceived.getText());
+ }
+ finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/pom.xml b/examples/protocols/pom.xml
index 7c86197..aa77336 100644
--- a/examples/protocols/pom.xml
+++ b/examples/protocols/pom.xml
@@ -30,7 +30,7 @@ under the License.
<groupId>org.apache.activemq.examples.protocols</groupId>
<artifactId>protocols</artifactId>
<packaging>pom</packaging>
- <name>ActiveMQ Artemis Clustered Examples</name>
+ <name>ActiveMQ Artemis Protocols Root Example</name>
<!-- Properties -->
<properties>
[3/4] activemq-artemis git commit: adding new OpenWire examples
Posted by cl...@apache.org.
adding new OpenWire examples
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a0cca441
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a0cca441
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a0cca441
Branch: refs/heads/master
Commit: a0cca441078f71c9e1362c3cc9d5a7fa59a39bfa
Parents: 1f0ea1c
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Aug 12 11:22:25 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Aug 12 13:04:33 2015 -0400
----------------------------------------------------------------------
.../activemq/artemis/util/ServerUtil.java | 33 +-
examples/broker-features/perf/perf/pom.xml | 156 +++++++
examples/broker-features/perf/perf/readme.html | 39 ++
.../activemq/artemis/jms/example/PerfBase.java | 409 +++++++++++++++++++
.../artemis/jms/example/PerfListener.java | 46 +++
.../artemis/jms/example/PerfParams.java | 158 +++++++
.../artemis/jms/example/PerfSender.java | 46 +++
.../activemq/artemis/jms/example/Server.java | 27 ++
.../main/resources/activemq/server0/broker.xml | 46 +++
.../perf/src/main/resources/jndi.properties | 20 +
.../perf/src/main/resources/perf.properties | 30 ++
examples/broker-features/perf/pom.xml | 50 +++
examples/broker-features/perf/soak/README | 85 ++++
examples/broker-features/perf/soak/pom.xml | 162 ++++++++
.../perf/soak/server0/broker.xml | 49 +++
.../broker-features/perf/soak/soak.properties | 30 ++
.../artemis/jms/soak/example/SoakBase.java | 116 ++++++
.../artemis/jms/soak/example/SoakParams.java | 158 +++++++
.../artemis/jms/soak/example/SoakReceiver.java | 190 +++++++++
.../artemis/jms/soak/example/SoakSender.java | 195 +++++++++
.../soak/src/main/resources/jndi.properties | 20 +
examples/broker-features/pom.xml | 2 +
examples/perf/perf/pom.xml | 156 -------
examples/perf/perf/readme.html | 39 --
.../activemq/artemis/jms/example/PerfBase.java | 409 -------------------
.../artemis/jms/example/PerfListener.java | 46 ---
.../artemis/jms/example/PerfParams.java | 158 -------
.../artemis/jms/example/PerfSender.java | 46 ---
.../activemq/artemis/jms/example/Server.java | 27 --
.../main/resources/activemq/server0/broker.xml | 46 ---
.../perf/src/main/resources/jndi.properties | 20 -
.../perf/src/main/resources/perf.properties | 30 --
examples/perf/pom.xml | 50 ---
examples/perf/soak/README | 85 ----
examples/perf/soak/pom.xml | 162 --------
examples/perf/soak/server0/broker.xml | 49 ---
examples/perf/soak/soak.properties | 30 --
.../artemis/jms/soak/example/SoakBase.java | 116 ------
.../artemis/jms/soak/example/SoakParams.java | 158 -------
.../artemis/jms/soak/example/SoakReceiver.java | 190 ---------
.../artemis/jms/soak/example/SoakSender.java | 195 ---------
.../soak/src/main/resources/jndi.properties | 20 -
examples/protocols/amqp/pom.xml | 8 +-
.../activemq/artemis/openwire/example/Chat.java | 3 -
.../protocols/openwire/message-listener/pom.xml | 116 ++++++
.../openwire/message-listener/readme.html | 35 ++
.../artemis/jms/example/QueueExample.java | 103 +++++
.../protocols/openwire/message-recovery/pom.xml | 102 +++++
.../openwire/message-recovery/readme.html | 35 ++
.../artemis/jms/example/QueueExample.java | 119 ++++++
examples/protocols/openwire/pom.xml | 7 +
examples/protocols/openwire/queue/pom.xml | 119 ++++++
examples/protocols/openwire/queue/readme.html | 39 ++
.../artemis/jms/example/QueueExample.java | 68 +++
examples/protocols/pom.xml | 2 +-
55 files changed, 2800 insertions(+), 2055 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
index 6c4689e..68916c3 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/util/ServerUtil.java
@@ -17,22 +17,22 @@
package org.apache.activemq.artemis.util;
-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.remoting.impl.netty.NettyConnectorFactory;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-
import javax.jms.Connection;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.HashMap;
+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.jms.client.ActiveMQConnection;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+
+/**
+ * A tool to let clients start, stop and kill Artemis servers
+ */
public class ServerUtil {
public static Process startServer(String artemisInstance, String serverName) throws Exception {
@@ -76,19 +76,20 @@ public class ServerUtil {
}
public static void waitForServerToStart(int id, int timeout) throws InterruptedException {
+ waitForServerToStart("tcp://localhost:" + (61616 + id), timeout);
+ }
+
+ public static void waitForServerToStart(String uri, long timeout) throws InterruptedException {
long realTimeout = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < realTimeout) {
try {
- HashMap<String, Object> params = new HashMap<String, Object>();
- params.put("host", "localhost");
- params.put("port", 61616 + id);
- TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
- ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
+ ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null);
cf.createConnection().close();
- System.out.println("server " + id + " started");
+ cf.close();
+ System.out.println("server " + uri + " started");
}
catch (Exception e) {
- System.out.println("awaiting server " + id + " start at " + (61616 + id));
+ System.out.println("awaiting server " + uri + " start at ");
Thread.sleep(500);
continue;
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/pom.xml b/examples/broker-features/perf/perf/pom.xml
new file mode 100644
index 0000000..bcab911
--- /dev/null
+++ b/examples/broker-features/perf/perf/pom.xml
@@ -0,0 +1,156 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>perf-root</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>perf</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS PerfExample Example</name>
+
+ <properties>
+ <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-server</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-commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>${netty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>server</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>runClient</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.example.Server</clientClass>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>perf</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>listener</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.apache.activemq.artemis.jms.example.PerfListener</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>sender</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>org.apache.activemq.artemis.jms.example.PerfSender</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/readme.html b/examples/broker-features/perf/perf/readme.html
new file mode 100644
index 0000000..aa42266
--- /dev/null
+++ b/examples/broker-features/perf/perf/readme.html
@@ -0,0 +1,39 @@
+<!--
+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.
+-->
+
+<html>
+ <head>
+ <title>ActiveMQ Artemis JMS Queue Selector Example</title>
+ <link rel="stylesheet" type="text/css" href="../../common/common.css" />
+ <link rel="stylesheet" type="text/css" href="../../common/prettify.css" />
+ <script type="text/javascript" src="../../common/prettify.js"></script>
+ </head>
+ <body onload="prettyPrint()">
+ <h1>JMS Simple Performance</h1>
+
+ <p>To start the server run <code>mvn verify -Pexample</code></p>
+
+ <p>To start the listener run <code>mvn -Plistener package</code></p>
+
+ <p>To start the sender run <code>mvn -Psender package</code></p>
+
+ <p>To configure the clients simply edit the <code>perf.properties</code> or <code>client.jndi.properties</code> in the
+ <code>src/main/resources</code> directory</p>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
new file mode 100644
index 0000000..bf18077
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
@@ -0,0 +1,409 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Random;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Logger;
+
+import org.apache.activemq.artemis.utils.TokenBucketLimiter;
+import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
+
+public abstract class PerfBase {
+
+ private static final Logger log = Logger.getLogger(PerfSender.class.getName());
+
+ private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "target/classes/perf.properties";
+
+ private static byte[] randomByteArray(final int length) {
+ byte[] bytes = new byte[length];
+
+ Random random = new Random();
+
+ for (int i = 0; i < length; i++) {
+ bytes[i] = Integer.valueOf(random.nextInt()).byteValue();
+ }
+
+ return bytes;
+ }
+
+ protected static String getPerfFileName(final String[] args) {
+ String fileName;
+
+ if (args.length > 0) {
+ fileName = args[0];
+ }
+ else {
+ fileName = PerfBase.DEFAULT_PERF_PROPERTIES_FILE_NAME;
+ }
+
+ return fileName;
+ }
+
+ protected static PerfParams getParams(final String fileName) throws Exception {
+ Properties props = null;
+
+ InputStream is = null;
+
+ try {
+ is = new FileInputStream(fileName);
+
+ props = new Properties();
+
+ props.load(is);
+ }
+ finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+
+ int noOfMessages = Integer.valueOf(props.getProperty("num-messages"));
+ int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages"));
+ int messageSize = Integer.valueOf(props.getProperty("message-size"));
+ boolean durable = Boolean.valueOf(props.getProperty("durable"));
+ boolean transacted = Boolean.valueOf(props.getProperty("transacted"));
+ int batchSize = Integer.valueOf(props.getProperty("batch-size"));
+ boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue"));
+ String destinationLookup = props.getProperty("destination-lookup");
+ String connectionFactoryLookup = props.getProperty("connection-factory-lookup");
+ int throttleRate = Integer.valueOf(props.getProperty("throttle-rate"));
+ boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
+ boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
+ boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
+
+ PerfBase.log.info("num-messages: " + noOfMessages);
+ PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages);
+ PerfBase.log.info("message-size: " + messageSize);
+ PerfBase.log.info("durable: " + durable);
+ PerfBase.log.info("transacted: " + transacted);
+ PerfBase.log.info("batch-size: " + batchSize);
+ PerfBase.log.info("drain-queue: " + drainQueue);
+ PerfBase.log.info("throttle-rate: " + throttleRate);
+ PerfBase.log.info("connection-factory-lookup: " + connectionFactoryLookup);
+ PerfBase.log.info("destination-lookup: " + destinationLookup);
+ PerfBase.log.info("disable-message-id: " + disableMessageID);
+ PerfBase.log.info("disable-message-timestamp: " + disableTimestamp);
+ PerfBase.log.info("dups-ok-acknowledge: " + dupsOK);
+
+ PerfParams perfParams = new PerfParams();
+ perfParams.setNoOfMessagesToSend(noOfMessages);
+ perfParams.setNoOfWarmupMessages(noOfWarmupMessages);
+ perfParams.setMessageSize(messageSize);
+ perfParams.setDurable(durable);
+ perfParams.setSessionTransacted(transacted);
+ perfParams.setBatchSize(batchSize);
+ perfParams.setDrainQueue(drainQueue);
+ perfParams.setConnectionFactoryLookup(connectionFactoryLookup);
+ perfParams.setDestinationLookup(destinationLookup);
+ perfParams.setThrottleRate(throttleRate);
+ perfParams.setDisableMessageID(disableMessageID);
+ perfParams.setDisableTimestamp(disableTimestamp);
+ perfParams.setDupsOK(dupsOK);
+
+ return perfParams;
+ }
+
+ private final PerfParams perfParams;
+
+ protected PerfBase(final PerfParams perfParams) {
+ this.perfParams = perfParams;
+ }
+
+ private ConnectionFactory factory;
+
+ private Connection connection;
+
+ private Session session;
+
+ private Destination destination;
+
+ private long start;
+
+ private void init() throws Exception {
+ InitialContext ic = new InitialContext();
+ System.out.println("ic = " + ic);
+ factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
+
+ destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
+
+ connection = factory.createConnection();
+
+ session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
+
+ ic.close();
+ }
+
+ private void displayAverage(final long numberOfMessages, final long start, final long end) {
+ double duration = (1.0 * end - start) / 1000; // in seconds
+ double average = 1.0 * numberOfMessages / duration;
+ PerfBase.log.info(String.format("average: %.2f msg/s (%d messages in %2.2fs)", average, numberOfMessages, duration));
+ }
+
+ protected void runSender() {
+ try {
+ init();
+
+ if (perfParams.isDrainQueue()) {
+ drainQueue();
+ }
+
+ start = System.currentTimeMillis();
+ PerfBase.log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages");
+ sendMessages(perfParams.getNoOfWarmupMessages(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), false, perfParams.getThrottleRate(), perfParams.getMessageSize());
+ PerfBase.log.info("warmed up");
+ start = System.currentTimeMillis();
+ sendMessages(perfParams.getNoOfMessagesToSend(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), true, perfParams.getThrottleRate(), perfParams.getMessageSize());
+ long end = System.currentTimeMillis();
+ displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ if (session != null) {
+ try {
+ session.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (connection != null) {
+ try {
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ protected void runListener() {
+ try {
+ init();
+
+ if (perfParams.isDrainQueue()) {
+ drainQueue();
+ }
+
+ MessageConsumer consumer = session.createConsumer(destination);
+
+ connection.start();
+
+ PerfBase.log.info("READY!!!");
+
+ CountDownLatch countDownLatch = new CountDownLatch(1);
+ consumer.setMessageListener(new PerfListener(countDownLatch, perfParams));
+ countDownLatch.await();
+ long end = System.currentTimeMillis();
+ // start was set on the first received message
+ displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ if (session != null) {
+ try {
+ session.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (connection != null) {
+ try {
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private void drainQueue() throws Exception {
+ PerfBase.log.info("Draining queue");
+
+ Session drainSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer consumer = drainSession.createConsumer(destination);
+
+ connection.start();
+
+ Message message = null;
+
+ int count = 0;
+ do {
+ message = consumer.receive(3000);
+
+ if (message != null) {
+ message.acknowledge();
+
+ count++;
+ }
+ } while (message != null);
+
+ drainSession.close();
+
+ PerfBase.log.info("Drained " + count + " messages");
+ }
+
+ private void sendMessages(final int numberOfMessages,
+ final int txBatchSize,
+ final boolean durable,
+ final boolean transacted,
+ final boolean display,
+ final int throttleRate,
+ final int messageSize) throws Exception {
+ MessageProducer producer = session.createProducer(destination);
+
+ producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ producer.setDisableMessageID(perfParams.isDisableMessageID());
+
+ producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
+
+ BytesMessage message = session.createBytesMessage();
+
+ byte[] payload = PerfBase.randomByteArray(messageSize);
+
+ message.writeBytes(payload);
+
+ final int modulo = 2000;
+
+ TokenBucketLimiter tbl = throttleRate != -1 ? new TokenBucketLimiterImpl(throttleRate, false) : null;
+
+ boolean committed = false;
+ for (int i = 1; i <= numberOfMessages; i++) {
+ producer.send(message);
+
+ if (transacted) {
+ if (i % txBatchSize == 0) {
+ session.commit();
+ committed = true;
+ }
+ else {
+ committed = false;
+ }
+ }
+
+ if (display && i % modulo == 0) {
+ double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+ PerfBase.log.info(String.format("sent %6d messages in %2.2fs", i, duration));
+ }
+
+ if (tbl != null) {
+ tbl.limit();
+ }
+ }
+ if (transacted && !committed) {
+ session.commit();
+ }
+ }
+
+ private class PerfListener implements MessageListener {
+
+ private final CountDownLatch countDownLatch;
+
+ private final PerfParams perfParams;
+
+ private boolean warmingUp = true;
+
+ private boolean started = false;
+
+ private final int modulo;
+
+ private final AtomicLong count = new AtomicLong(0);
+
+ public PerfListener(final CountDownLatch countDownLatch, final PerfParams perfParams) {
+ this.countDownLatch = countDownLatch;
+ this.perfParams = perfParams;
+ warmingUp = perfParams.getNoOfWarmupMessages() > 0;
+ modulo = 2000;
+ }
+
+ public void onMessage(final Message message) {
+ try {
+ if (warmingUp) {
+ boolean committed = checkCommit();
+ if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) {
+ PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs");
+ if (!committed) {
+ checkCommit();
+ }
+ warmingUp = false;
+ }
+ return;
+ }
+
+ if (!started) {
+ started = true;
+ // reset count to take stats
+ count.set(0);
+ start = System.currentTimeMillis();
+ }
+
+ long currentCount = count.incrementAndGet();
+ boolean committed = checkCommit();
+ if (currentCount == perfParams.getNoOfMessagesToSend()) {
+ if (!committed) {
+ checkCommit();
+ }
+ countDownLatch.countDown();
+ }
+ if (currentCount % modulo == 0) {
+ double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
+ PerfBase.log.info(String.format("received %6d messages in %2.2fs", currentCount, duration));
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private boolean checkCommit() throws Exception {
+ if (perfParams.isSessionTransacted()) {
+ if (count.longValue() % perfParams.getBatchSize() == 0) {
+ session.commit();
+
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
new file mode 100644
index 0000000..3f2c478
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
@@ -0,0 +1,46 @@
+/*
+ * 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.jms.example;
+
+import java.util.logging.Logger;
+
+public class PerfListener extends PerfBase {
+
+ private static final Logger log = Logger.getLogger(PerfListener.class.getName());
+
+ public static void main(final String[] args) {
+ try {
+ String fileName = PerfBase.getPerfFileName(args);
+
+ PerfParams params = PerfBase.getParams(fileName);
+
+ new PerfListener(params).run();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private PerfListener(final PerfParams perfParams) {
+ super(perfParams);
+ }
+
+ public void run() throws Exception {
+ runListener();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
new file mode 100644
index 0000000..c358171
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
@@ -0,0 +1,158 @@
+/*
+ * 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.jms.example;
+
+import java.io.Serializable;
+
+/**
+ * Class that holds the parameters used in the performance examples
+ */
+public class PerfParams implements Serializable {
+
+ private static final long serialVersionUID = -4336539641012356002L;
+
+ private int noOfMessagesToSend = 1000;
+
+ private int noOfWarmupMessages;
+
+ private int messageSize = 1024; // in bytes
+
+ private boolean durable = false;
+
+ private boolean isSessionTransacted = false;
+
+ private int batchSize = 5000;
+
+ private boolean drainQueue = true;
+
+ private String connectionFactoryLookup;
+
+ private String destinationLookup;
+
+ private int throttleRate;
+
+ private boolean disableMessageID;
+
+ private boolean disableTimestamp;
+
+ private boolean dupsOK;
+
+ public synchronized int getNoOfMessagesToSend() {
+ return noOfMessagesToSend;
+ }
+
+ public synchronized void setNoOfMessagesToSend(final int noOfMessagesToSend) {
+ this.noOfMessagesToSend = noOfMessagesToSend;
+ }
+
+ public synchronized int getNoOfWarmupMessages() {
+ return noOfWarmupMessages;
+ }
+
+ public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) {
+ this.noOfWarmupMessages = noOfWarmupMessages;
+ }
+
+ public synchronized int getMessageSize() {
+ return messageSize;
+ }
+
+ public synchronized void setMessageSize(final int messageSize) {
+ this.messageSize = messageSize;
+ }
+
+ public synchronized boolean isDurable() {
+ return durable;
+ }
+
+ public synchronized void setDurable(final boolean durable) {
+ this.durable = durable;
+ }
+
+ public synchronized boolean isSessionTransacted() {
+ return isSessionTransacted;
+ }
+
+ public synchronized void setSessionTransacted(final boolean isSessionTransacted) {
+ this.isSessionTransacted = isSessionTransacted;
+ }
+
+ public synchronized int getBatchSize() {
+ return batchSize;
+ }
+
+ public synchronized void setBatchSize(final int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public synchronized boolean isDrainQueue() {
+ return drainQueue;
+ }
+
+ public synchronized void setDrainQueue(final boolean drainQueue) {
+ this.drainQueue = drainQueue;
+ }
+
+ public synchronized String getConnectionFactoryLookup() {
+ return connectionFactoryLookup;
+ }
+
+ public synchronized void setConnectionFactoryLookup(final String connectionFactoryLookup) {
+ this.connectionFactoryLookup = connectionFactoryLookup;
+ }
+
+ public synchronized String getDestinationLookup() {
+ return destinationLookup;
+ }
+
+ public synchronized void setDestinationLookup(final String destinationLookup) {
+ this.destinationLookup = destinationLookup;
+ }
+
+ public synchronized int getThrottleRate() {
+ return throttleRate;
+ }
+
+ public synchronized void setThrottleRate(final int throttleRate) {
+ this.throttleRate = throttleRate;
+ }
+
+ public synchronized boolean isDisableMessageID() {
+ return disableMessageID;
+ }
+
+ public synchronized void setDisableMessageID(final boolean disableMessageID) {
+ this.disableMessageID = disableMessageID;
+ }
+
+ public synchronized boolean isDisableTimestamp() {
+ return disableTimestamp;
+ }
+
+ public synchronized void setDisableTimestamp(final boolean disableTimestamp) {
+ this.disableTimestamp = disableTimestamp;
+ }
+
+ public synchronized boolean isDupsOK() {
+ return dupsOK;
+ }
+
+ public synchronized void setDupsOK(final boolean dupsOK) {
+ this.dupsOK = dupsOK;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
new file mode 100644
index 0000000..6649bfa
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
@@ -0,0 +1,46 @@
+/*
+ * 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.jms.example;
+
+import java.util.logging.Logger;
+
+public class PerfSender extends PerfBase {
+
+ private static final Logger log = Logger.getLogger(PerfSender.class.getName());
+
+ public static void main(final String[] args) {
+ try {
+ String fileName = PerfBase.getPerfFileName(args);
+
+ PerfParams params = PerfBase.getParams(fileName);
+
+ new PerfSender(params).run();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private PerfSender(final PerfParams perfParams) {
+ super(perfParams);
+ }
+
+ public void run() throws Exception {
+ runSender();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
new file mode 100644
index 0000000..33ccd0e
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
@@ -0,0 +1,27 @@
+/*
+ * 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.jms.example;
+
+public class Server {
+
+ public static void main(String[] arg) {
+ System.out.println("***********************************************************************************");
+ System.out.println("You need to start manually under ./target/server/bin just run ./artemis run");
+ System.out.println("***********************************************************************************");
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 0000000..a642ac5
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,46 @@
+<?xml version='1.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.
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:activemq"
+ xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+
+ <jms xmlns="urn:activemq:jms">
+ <queue name="perfQueue"/>
+ </jms>
+
+ <core xmlns="urn:activemq:core">
+
+ <security-enabled>false</security-enabled>
+ <persistence-enabled>true</persistence-enabled>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor>
+ </acceptors>
+
+ <queues>
+ <queue name="perfQueue">
+ <address>perfAddress</address>
+ </queue>
+ </queues>
+
+ </core>
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/resources/jndi.properties b/examples/broker-features/perf/perf/src/main/resources/jndi.properties
new file mode 100644
index 0000000..bcf6926
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/resources/jndi.properties
@@ -0,0 +1,20 @@
+# 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.
+
+java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
+connectionFactory.ConnectionFactory=tcp://localhost:61616?tcp-no-delay=false&tcp-send-buffer-size=1048576&tcp-receive-buffer-size=1048576
+queue.perfQueue=perfQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/perf/src/main/resources/perf.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/perf/src/main/resources/perf.properties b/examples/broker-features/perf/perf/src/main/resources/perf.properties
new file mode 100644
index 0000000..f5ca7be
--- /dev/null
+++ b/examples/broker-features/perf/perf/src/main/resources/perf.properties
@@ -0,0 +1,30 @@
+# 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.
+
+num-messages=100000
+num-warmup-messages=1000
+message-size=1024
+durable=false
+transacted=false
+batch-size=1000
+drain-queue=false
+destination-lookup=perfQueue
+connection-factory-lookup=ConnectionFactory
+throttle-rate=-1
+dups-ok-acknowledge=false
+disable-message-id=true
+disable-message-timestamp=true
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/pom.xml b/examples/broker-features/perf/pom.xml
new file mode 100644
index 0000000..eaafdaf
--- /dev/null
+++ b/examples/broker-features/perf/pom.xml
@@ -0,0 +1,50 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples</groupId>
+ <artifactId>artemis-examples</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>perf-root</artifactId>
+ <packaging>pom</packaging>
+ <name>ActiveMQ Artemis Performance Examples</name>
+
+ <!-- Properties -->
+ <properties>
+ <!--
+ Explicitly declaring the source encoding eliminates the following
+ message: [WARNING] Using platform encoding (UTF-8 actually) to copy
+ filtered resources, i.e. build is platform dependent!
+ -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <activemq.basedir>${project.basedir}/../../..</activemq.basedir>
+ </properties>
+
+ <modules>
+ <module>perf</module>
+ <module>soak</module>
+ </modules>
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/README
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/README b/examples/broker-features/perf/soak/README
new file mode 100644
index 0000000..b69a1ac
--- /dev/null
+++ b/examples/broker-features/perf/soak/README
@@ -0,0 +1,85 @@
+****************************************************
+* Soak Test For Manual Reconnection of JMS Clients *
+****************************************************
+
+Running the Soak Tests
+=======================
+
+Run The Server Standalone
+==========================
+
+Use the Profile server
+ mvn -Pserver verify
+
+That will create a server under ./target/server0
+
+
+You can define the property server.dir under the same Profile to create other servers. or you could do it manually if desired using the regular ./artemis create
+
+ $ mvn -Dserver.dir=server1 -Pserver verify
+
+server1 should contain a copy of configuration equivalent to that found under the server0 director with different
+settings.
+
+To run a server with the same configuration but on a different host. Check out this source on the host machine and
+change:
+* activemq.remoting.netty.host property in broker.xml
+* bindAddress and rmiBindAddress properties in activemq-beans.xml
+
+ $ mvn verify -P server
+
+
+To run the server just start it manually
+
+Configure Server Dump
+=====================
+
+The server can "dump" info at regular interval. In broker.xml, set
+
+ <server-dump-interval>10000</server-dump-interval>
+
+to have infos every 10s:
+
+**** Server Dump ****
+date: Mon Aug 17 18:19:07 CEST 2009
+free memory: 500,79 MiB
+max memory: 1,95 GiB
+total memory: 507,13 MiB
+available memory: 99,68%
+total paging memory: 0,00 B
+# of thread: 19
+# of conns: 0
+********************
+
+Run The Clients
+===============
+
+The clients can be run separate from the server using:
+
+ $ mvn verify -Premote
+
+Parameters are specified in soak.properties.
+
+The duration of the tests is configured by duration-in-minutes (defaults to 2 minutes, set to
+-1 to run the test indefinitely).
+
+To configure the soak properties different to the defaults for the clients, use the system property
+To specify the JNDI server to connect to, use the system property jndi.address
+
+ $ mvn verify -Premote -Dsoak.props=<path to properties> -Pjndi.address=jnp:remote.host:1099
+
+Every 1000th message, the clients will display their recent activity:
+
+INFO: received 10000 messages in 5,71s (total: 55s)
+
+At the end of the run, the sender and receiver will sum up their activity:
+
+INFO: Received 223364 messages in 2,01 minutes
+
+Kill The Server And Check Manual Reconnection
+==============================================
+
+You can kill the server (ctl+c or kill -9), the clients are configured to reconnect
+indefinitely to the same single server (even in case of clean shutdown)
+Once the server restarts, all the clients will resume their activities after reconnecting
+to the server.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/pom.xml b/examples/broker-features/perf/soak/pom.xml
new file mode 100644
index 0000000..eb07b0b
--- /dev/null
+++ b/examples/broker-features/perf/soak/pom.xml
@@ -0,0 +1,162 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>artemis-jms-soak-example</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis Soak Normal Example</name>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>perf-root</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-jms-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <server.dir>${basedir}/server0/</server.dir>
+ <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>server</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ <configuration>
+ <instance>${basedir}/target/server0</instance>
+ <configuration>${basedir}/server0</configuration>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>artemis-jms-soak-example</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>local</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>runConsumer</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakReceiver</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>runProducer</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakSender</clientClass>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>artemis-jms-soak-example</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>remote</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>runConsumer</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakReceiver</clientClass>
+ <args>
+ <param>tcp://localhost:61616</param>
+ </args>
+ </configuration>
+ </execution>
+ <execution>
+ <id>runProducer</id>
+ <goals>
+ <goal>runClient</goal>
+ </goals>
+ <configuration>
+ <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakSender</clientClass>
+ <args>
+ <param>tcp://localhost:61616</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.soak</groupId>
+ <artifactId>artemis-jms-soak-example</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/server0/broker.xml b/examples/broker-features/perf/soak/server0/broker.xml
new file mode 100644
index 0000000..76df21f
--- /dev/null
+++ b/examples/broker-features/perf/soak/server0/broker.xml
@@ -0,0 +1,49 @@
+<?xml version='1.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.
+-->
+<configuration xmlns="urn:activemq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+ <jms xmlns="urn:activemq:jms">
+ <queue name="soakQueue"/>
+ </jms>
+ <core xmlns="urn:activemq:core">
+ <connectors>
+ <connector name="netty-connector">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor>
+ </acceptors>
+
+ <security-enabled>false</security-enabled>
+
+ <persistence-enabled>false</persistence-enabled>
+
+ <server-dump-interval>30000</server-dump-interval>
+
+ <queues>
+ <queue name="soakQueue">
+ <address>soakAddress</address>
+ </queue>
+ </queues>
+ </core>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/soak.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/soak.properties b/examples/broker-features/perf/soak/soak.properties
new file mode 100644
index 0000000..2ccff7d
--- /dev/null
+++ b/examples/broker-features/perf/soak/soak.properties
@@ -0,0 +1,30 @@
+# 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.
+
+duration-in-minutes=2
+num-warmup-messages=100
+message-size=1024
+durable=true
+transacted=false
+batch-size=1000
+drain-queue=false
+destination-lookup=soakQueue
+connection-factory-lookup=/ConnectionFactory
+throttle-rate=-1
+dups-ok-acknowledge=false
+disable-message-id=true
+disable-message-timestamp=true
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
new file mode 100644
index 0000000..ce5b9bc
--- /dev/null
+++ b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
@@ -0,0 +1,116 @@
+/*
+ * 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.jms.soak.example;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Random;
+import java.util.logging.Logger;
+
+public class SoakBase {
+
+ private static final Logger log = Logger.getLogger(SoakBase.class.getName());
+
+ private static final String DEFAULT_SOAK_PROPERTIES_FILE_NAME = "soak.properties";
+
+ public static final int TO_MILLIS = 60 * 1000; // from minute to milliseconds
+
+ public static byte[] randomByteArray(final int length) {
+ byte[] bytes = new byte[length];
+
+ Random random = new Random();
+
+ for (int i = 0; i < length; i++) {
+ bytes[i] = Integer.valueOf(random.nextInt()).byteValue();
+ }
+
+ return bytes;
+ }
+
+ protected static String getPerfFileName() {
+ String fileName = System.getProperty("soak.props");
+ if (fileName == null) {
+ fileName = SoakBase.DEFAULT_SOAK_PROPERTIES_FILE_NAME;
+ }
+ return fileName;
+ }
+
+ protected static SoakParams getParams(final String fileName) throws Exception {
+ Properties props = null;
+
+ InputStream is = null;
+
+ try {
+ is = new FileInputStream(fileName);
+
+ props = new Properties();
+
+ props.load(is);
+ }
+ finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+
+ int durationInMinutes = Integer.valueOf(props.getProperty("duration-in-minutes"));
+ int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages"));
+ int messageSize = Integer.valueOf(props.getProperty("message-size"));
+ boolean durable = Boolean.valueOf(props.getProperty("durable"));
+ boolean transacted = Boolean.valueOf(props.getProperty("transacted"));
+ int batchSize = Integer.valueOf(props.getProperty("batch-size"));
+ boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue"));
+ String destinationLookup = props.getProperty("destination-lookup");
+ String connectionFactoryLookup = props.getProperty("connection-factory-lookup");
+ int throttleRate = Integer.valueOf(props.getProperty("throttle-rate"));
+ boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
+ boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
+ boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
+
+ SoakBase.log.info("duration-in-minutes: " + durationInMinutes);
+ SoakBase.log.info("num-warmup-messages: " + noOfWarmupMessages);
+ SoakBase.log.info("message-size: " + messageSize);
+ SoakBase.log.info("durable: " + durable);
+ SoakBase.log.info("transacted: " + transacted);
+ SoakBase.log.info("batch-size: " + batchSize);
+ SoakBase.log.info("drain-queue: " + drainQueue);
+ SoakBase.log.info("throttle-rate: " + throttleRate);
+ SoakBase.log.info("connection-factory-lookup: " + connectionFactoryLookup);
+ SoakBase.log.info("destination-lookup: " + destinationLookup);
+ SoakBase.log.info("disable-message-id: " + disableMessageID);
+ SoakBase.log.info("disable-message-timestamp: " + disableTimestamp);
+ SoakBase.log.info("dups-ok-acknowledge: " + dupsOK);
+
+ SoakParams soakParams = new SoakParams();
+ soakParams.setDurationInMinutes(durationInMinutes);
+ soakParams.setNoOfWarmupMessages(noOfWarmupMessages);
+ soakParams.setMessageSize(messageSize);
+ soakParams.setDurable(durable);
+ soakParams.setSessionTransacted(transacted);
+ soakParams.setBatchSize(batchSize);
+ soakParams.setDrainQueue(drainQueue);
+ soakParams.setConnectionFactoryLookup(connectionFactoryLookup);
+ soakParams.setDestinationLookup(destinationLookup);
+ soakParams.setThrottleRate(throttleRate);
+ soakParams.setDisableMessageID(disableMessageID);
+ soakParams.setDisableTimestamp(disableTimestamp);
+ soakParams.setDupsOK(dupsOK);
+
+ return soakParams;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
new file mode 100644
index 0000000..dda2ac1
--- /dev/null
+++ b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
@@ -0,0 +1,158 @@
+/*
+ * 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.jms.soak.example;
+
+import java.io.Serializable;
+
+/**
+ * Class that holds the parameters used in the performance examples
+ */
+public class SoakParams implements Serializable {
+
+ private static final long serialVersionUID = -4336539641012356002L;
+
+ private int durationInMinutes = 60;
+
+ private int noOfWarmupMessages;
+
+ private int messageSize = 1024; // in bytes
+
+ private boolean durable = false;
+
+ private boolean isSessionTransacted = false;
+
+ private int batchSize = 5000;
+
+ private boolean drainQueue = true;
+
+ private String connectionFactoryLookup;
+
+ private String destinationLookup;
+
+ private int throttleRate;
+
+ private boolean disableMessageID;
+
+ private boolean disableTimestamp;
+
+ private boolean dupsOK;
+
+ public synchronized int getDurationInMinutes() {
+ return durationInMinutes;
+ }
+
+ public synchronized void setDurationInMinutes(final int durationInMinutes) {
+ this.durationInMinutes = durationInMinutes;
+ }
+
+ public synchronized int getNoOfWarmupMessages() {
+ return noOfWarmupMessages;
+ }
+
+ public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) {
+ this.noOfWarmupMessages = noOfWarmupMessages;
+ }
+
+ public synchronized int getMessageSize() {
+ return messageSize;
+ }
+
+ public synchronized void setMessageSize(final int messageSize) {
+ this.messageSize = messageSize;
+ }
+
+ public synchronized boolean isDurable() {
+ return durable;
+ }
+
+ public synchronized void setDurable(final boolean durable) {
+ this.durable = durable;
+ }
+
+ public synchronized boolean isSessionTransacted() {
+ return isSessionTransacted;
+ }
+
+ public synchronized void setSessionTransacted(final boolean isSessionTransacted) {
+ this.isSessionTransacted = isSessionTransacted;
+ }
+
+ public synchronized int getBatchSize() {
+ return batchSize;
+ }
+
+ public synchronized void setBatchSize(final int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public synchronized boolean isDrainQueue() {
+ return drainQueue;
+ }
+
+ public synchronized void setDrainQueue(final boolean drainQueue) {
+ this.drainQueue = drainQueue;
+ }
+
+ public synchronized String getConnectionFactoryLookup() {
+ return connectionFactoryLookup;
+ }
+
+ public synchronized void setConnectionFactoryLookup(final String connectionFactoryLookup) {
+ this.connectionFactoryLookup = connectionFactoryLookup;
+ }
+
+ public synchronized String getDestinationLookup() {
+ return destinationLookup;
+ }
+
+ public synchronized void setDestinationLookup(final String destinationLookup) {
+ this.destinationLookup = destinationLookup;
+ }
+
+ public synchronized int getThrottleRate() {
+ return throttleRate;
+ }
+
+ public synchronized void setThrottleRate(final int throttleRate) {
+ this.throttleRate = throttleRate;
+ }
+
+ public synchronized boolean isDisableMessageID() {
+ return disableMessageID;
+ }
+
+ public synchronized void setDisableMessageID(final boolean disableMessageID) {
+ this.disableMessageID = disableMessageID;
+ }
+
+ public synchronized boolean isDisableTimestamp() {
+ return disableTimestamp;
+ }
+
+ public synchronized void setDisableTimestamp(final boolean disableTimestamp) {
+ this.disableTimestamp = disableTimestamp;
+ }
+
+ public synchronized boolean isDupsOK() {
+ return dupsOK;
+ }
+
+ public synchronized void setDupsOK(final boolean dupsOK) {
+ this.dupsOK = dupsOK;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
new file mode 100644
index 0000000..ce39968
--- /dev/null
+++ b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
@@ -0,0 +1,190 @@
+/*
+ * 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.jms.soak.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Logger;
+
+public class SoakReceiver {
+
+ private static final Logger log = Logger.getLogger(SoakReceiver.class.getName());
+
+ private static final String EOF = UUID.randomUUID().toString();
+
+ public static void main(final String[] args) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+
+ try {
+ String fileName = SoakBase.getPerfFileName();
+
+ SoakParams params = SoakBase.getParams(fileName);
+
+ final SoakReceiver receiver = new SoakReceiver(params);
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ receiver.disconnect();
+ }
+ });
+
+ receiver.run();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Thread t = new Thread(runnable);
+ t.start();
+ }
+
+ private final SoakParams perfParams;
+
+ private final ExceptionListener exceptionListener = new ExceptionListener() {
+ public void onException(final JMSException e) {
+ disconnect();
+ connect();
+ }
+ };
+
+ private final MessageListener listener = new MessageListener() {
+ int modulo = 10000;
+
+ private final AtomicLong count = new AtomicLong(0);
+
+ private final long start = System.currentTimeMillis();
+
+ long moduloStart = start;
+
+ public void onMessage(final Message msg) {
+ long totalDuration = System.currentTimeMillis() - start;
+
+ try {
+ if (SoakReceiver.EOF.equals(msg.getStringProperty("eof"))) {
+ SoakReceiver.log.info(String.format("Received %s messages in %.2f minutes", count, 1.0 * totalDuration / SoakBase.TO_MILLIS));
+ SoakReceiver.log.info("END OF RUN");
+
+ return;
+ }
+ }
+ catch (JMSException e1) {
+ e1.printStackTrace();
+ }
+ if (count.incrementAndGet() % modulo == 0) {
+ double duration = (1.0 * System.currentTimeMillis() - moduloStart) / 1000;
+ moduloStart = System.currentTimeMillis();
+ SoakReceiver.log.info(String.format("received %s messages in %2.2fs (total: %.0fs)", modulo, duration, totalDuration / 1000.0));
+ }
+ }
+ };
+
+ private Session session;
+
+ private Connection connection;
+
+ private SoakReceiver(final SoakParams perfParams) {
+ this.perfParams = perfParams;
+ }
+
+ public void run() throws Exception {
+ connect();
+
+ boolean runInfinitely = perfParams.getDurationInMinutes() == -1;
+
+ if (!runInfinitely) {
+ Thread.sleep(perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS);
+
+ // send EOF message
+ Message eof = session.createMessage();
+ eof.setStringProperty("eof", SoakReceiver.EOF);
+ listener.onMessage(eof);
+
+ if (connection != null) {
+ connection.close();
+ connection = null;
+ }
+ }
+ else {
+ while (true) {
+ Thread.sleep(500);
+ }
+ }
+ }
+
+ private void disconnect() {
+ if (connection != null) {
+ try {
+ connection.setExceptionListener(null);
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ finally {
+ connection = null;
+ }
+ }
+ }
+
+ private void connect() {
+ InitialContext ic = null;
+ try {
+ ic = new InitialContext();
+
+ ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
+
+ Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
+
+ connection = factory.createConnection();
+ connection.setExceptionListener(exceptionListener);
+
+ session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer messageConsumer = session.createConsumer(destination);
+ messageConsumer.setMessageListener(listener);
+
+ connection.start();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ ic.close();
+ }
+ catch (NamingException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
new file mode 100644
index 0000000..10fbbd8
--- /dev/null
+++ b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
@@ -0,0 +1,195 @@
+/*
+ * 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.jms.soak.example;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.logging.Logger;
+
+import org.apache.activemq.artemis.utils.TokenBucketLimiter;
+import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
+
+public class SoakSender {
+
+ private static final Logger log = Logger.getLogger(SoakSender.class.getName());
+
+ public static void main(final String[] args) {
+ try {
+ String fileName = SoakBase.getPerfFileName();
+
+ SoakParams params = SoakBase.getParams(fileName);
+ final SoakSender sender = new SoakSender(params);
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ sender.disconnect();
+ }
+ });
+
+ sender.run();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private final SoakParams perfParams;
+
+ private Connection connection;
+
+ private Session session;
+
+ private MessageProducer producer;
+
+ private final ExceptionListener exceptionListener = new ExceptionListener() {
+ public void onException(final JMSException e) {
+ System.out.println("SoakReconnectableSender.exceptionListener.new ExceptionListener() {...}.onException()");
+ disconnect();
+ connect();
+ }
+
+ };
+
+ private SoakSender(final SoakParams perfParams) {
+ this.perfParams = perfParams;
+ }
+
+ public void run() throws Exception {
+ connect();
+
+ boolean runInfinitely = perfParams.getDurationInMinutes() == -1;
+
+ BytesMessage message = session.createBytesMessage();
+
+ byte[] payload = SoakBase.randomByteArray(perfParams.getMessageSize());
+
+ message.writeBytes(payload);
+
+ final int modulo = 10000;
+
+ TokenBucketLimiter tbl = perfParams.getThrottleRate() != -1 ? new TokenBucketLimiterImpl(perfParams.getThrottleRate(), false) : null;
+
+ boolean transacted = perfParams.isSessionTransacted();
+ int txBatchSize = perfParams.getBatchSize();
+ boolean display = true;
+
+ long start = System.currentTimeMillis();
+ long moduleStart = start;
+ AtomicLong count = new AtomicLong(0);
+ while (true) {
+ try {
+ producer.send(message);
+ count.incrementAndGet();
+
+ if (transacted) {
+ if (count.longValue() % txBatchSize == 0) {
+ session.commit();
+ }
+ }
+
+ long totalDuration = System.currentTimeMillis() - start;
+
+ if (display && count.longValue() % modulo == 0) {
+ double duration = (1.0 * System.currentTimeMillis() - moduleStart) / 1000;
+ moduleStart = System.currentTimeMillis();
+ SoakSender.log.info(String.format("sent %s messages in %2.2fs (time: %.0fs)", modulo, duration, totalDuration / 1000.0));
+ }
+
+ if (tbl != null) {
+ tbl.limit();
+ }
+
+ if (!runInfinitely && totalDuration > perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS) {
+ break;
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ SoakSender.log.info(String.format("Sent %s messages in %s minutes", count, perfParams.getDurationInMinutes()));
+ SoakSender.log.info("END OF RUN");
+
+ if (connection != null) {
+ connection.close();
+ connection = null;
+ }
+ }
+
+ private synchronized void disconnect() {
+ if (connection != null) {
+ try {
+ connection.setExceptionListener(null);
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ finally {
+ connection = null;
+ }
+ }
+ }
+
+ private void connect() {
+ InitialContext ic = null;
+ try {
+ ic = new InitialContext();
+
+ ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
+
+ Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
+
+ connection = factory.createConnection();
+
+ session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
+
+ producer = session.createProducer(destination);
+
+ producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ producer.setDisableMessageID(perfParams.isDisableMessageID());
+
+ producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
+
+ connection.setExceptionListener(exceptionListener);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ ic.close();
+ }
+ catch (NamingException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/perf/soak/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/perf/soak/src/main/resources/jndi.properties b/examples/broker-features/perf/soak/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/broker-features/perf/soak/src/main/resources/jndi.properties
@@ -0,0 +1,20 @@
+# 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.
+
+java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
+connectionFactory.ConnectionFactory=tcp://localhost:61616
+queue.queue/exampleQueue=exampleQueue
[4/4] activemq-artemis git commit: removing tabs from native
Posted by cl...@apache.org.
removing tabs from native
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/f369142e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/f369142e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/f369142e
Branch: refs/heads/master
Commit: f369142e28fe0cc3e0f385ae416ee51a142acaa3
Parents: a0cca44
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Aug 12 13:04:49 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Aug 12 13:04:49 2015 -0400
----------------------------------------------------------------------
...che_activemq_artemis_jlibaio_LibaioContext.c | 64 ++++++++++----------
1 file changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/f369142e/artemis-native/src/main/c/org_apache_activemq_artemis_jlibaio_LibaioContext.c
----------------------------------------------------------------------
diff --git a/artemis-native/src/main/c/org_apache_activemq_artemis_jlibaio_LibaioContext.c b/artemis-native/src/main/c/org_apache_activemq_artemis_jlibaio_LibaioContext.c
index b6fcdd3..4776966 100644
--- a/artemis-native/src/main/c/org_apache_activemq_artemis_jlibaio_LibaioContext.c
+++ b/artemis-native/src/main/c/org_apache_activemq_artemis_jlibaio_LibaioContext.c
@@ -625,44 +625,44 @@ JNIEXPORT jint JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_ge
JNIEXPORT jlong JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_getSize
(JNIEnv * env, jclass clazz, jint fd)
{
- struct stat statBuffer;
-
- if (fstat(fd, &statBuffer) < 0)
- {
- throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
- return -1l;
- }
- return statBuffer.st_size;
+ struct stat statBuffer;
+
+ if (fstat(fd, &statBuffer) < 0)
+ {
+ throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
+ return -1l;
+ }
+ return statBuffer.st_size;
}
JNIEXPORT jint JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_getBlockSizeFD
(JNIEnv * env, jclass clazz, jint fd)
{
- struct stat statBuffer;
-
- if (fstat(fd, &statBuffer) < 0)
- {
- throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
- return -1l;
- }
- return statBuffer.st_blksize;
+ struct stat statBuffer;
+
+ if (fstat(fd, &statBuffer) < 0)
+ {
+ throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
+ return -1l;
+ }
+ return statBuffer.st_blksize;
}
JNIEXPORT jint JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_getBlockSize
(JNIEnv * env, jclass clazz, jstring path)
{
const char* f_path = (*env)->GetStringUTFChars(env, path, 0);
- struct stat statBuffer;
+ struct stat statBuffer;
- if (stat(f_path, &statBuffer) < 0)
- {
- throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
- return -1l;
- }
+ if (stat(f_path, &statBuffer) < 0)
+ {
+ throwIOExceptionErrorNo(env, "Cannot determine file size:", errno);
+ return -1l;
+ }
(*env)->ReleaseStringUTFChars(env, path, f_path);
- return statBuffer.st_blksize;
+ return statBuffer.st_blksize;
}
JNIEXPORT void JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_fallocate
@@ -679,17 +679,17 @@ JNIEXPORT void JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_fa
JNIEXPORT void JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_fill
(JNIEnv * env, jclass clazz, jint fd, jlong size)
{
- void * preAllocBuffer = 0;
- if (posix_memalign(&preAllocBuffer, 512, size) != 0)
- {
- throwOutOfMemoryError(env);
- return;
- }
- memset(preAllocBuffer, 0, size);
+ void * preAllocBuffer = 0;
+ if (posix_memalign(&preAllocBuffer, 512, size) != 0)
+ {
+ throwOutOfMemoryError(env);
+ return;
+ }
+ memset(preAllocBuffer, 0, size);
lseek (fd, 0, SEEK_SET);
write(fd, preAllocBuffer, size);
- lseek (fd, 0, SEEK_SET);
- free (preAllocBuffer);
+ lseek (fd, 0, SEEK_SET);
+ free (preAllocBuffer);
}
JNIEXPORT void JNICALL Java_org_apache_activemq_artemis_jlibaio_LibaioContext_memsetBuffer
[2/4] activemq-artemis git commit: adding new OpenWire examples
Posted by cl...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/broker-features/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/pom.xml b/examples/broker-features/pom.xml
index 6d1aa13..f5afbee 100644
--- a/examples/broker-features/pom.xml
+++ b/examples/broker-features/pom.xml
@@ -51,6 +51,7 @@ under the License.
<module>ha</module>
<module>standard</module>
<module>sub-modules</module>
+ <module>perf</module>
</modules>
</profile>
<profile>
@@ -60,6 +61,7 @@ under the License.
<module>ha</module>
<module>standard</module>
<module>sub-modules</module>
+ <module>perf</module>
</modules>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/perf/perf/pom.xml b/examples/perf/perf/pom.xml
deleted file mode 100644
index 3fb9aed..0000000
--- a/examples/perf/perf/pom.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>perf-root</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>perf</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS PerfExample Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-server</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-commons</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>${netty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>server</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- <execution>
- <id>runClient</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.example.Server</clientClass>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>perf</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>listener</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>org.apache.activemq.artemis.jms.example.PerfListener</mainClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>sender</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>java</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <mainClass>org.apache.activemq.artemis.jms.example.PerfSender</mainClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/readme.html
----------------------------------------------------------------------
diff --git a/examples/perf/perf/readme.html b/examples/perf/perf/readme.html
deleted file mode 100644
index aa42266..0000000
--- a/examples/perf/perf/readme.html
+++ /dev/null
@@ -1,39 +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.
--->
-
-<html>
- <head>
- <title>ActiveMQ Artemis JMS Queue Selector Example</title>
- <link rel="stylesheet" type="text/css" href="../../common/common.css" />
- <link rel="stylesheet" type="text/css" href="../../common/prettify.css" />
- <script type="text/javascript" src="../../common/prettify.js"></script>
- </head>
- <body onload="prettyPrint()">
- <h1>JMS Simple Performance</h1>
-
- <p>To start the server run <code>mvn verify -Pexample</code></p>
-
- <p>To start the listener run <code>mvn -Plistener package</code></p>
-
- <p>To start the sender run <code>mvn -Psender package</code></p>
-
- <p>To configure the clients simply edit the <code>perf.properties</code> or <code>client.jndi.properties</code> in the
- <code>src/main/resources</code> directory</p>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
deleted file mode 100644
index bf18077..0000000
--- a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.Random;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-import org.apache.activemq.artemis.utils.TokenBucketLimiter;
-import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
-
-public abstract class PerfBase {
-
- private static final Logger log = Logger.getLogger(PerfSender.class.getName());
-
- private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "target/classes/perf.properties";
-
- private static byte[] randomByteArray(final int length) {
- byte[] bytes = new byte[length];
-
- Random random = new Random();
-
- for (int i = 0; i < length; i++) {
- bytes[i] = Integer.valueOf(random.nextInt()).byteValue();
- }
-
- return bytes;
- }
-
- protected static String getPerfFileName(final String[] args) {
- String fileName;
-
- if (args.length > 0) {
- fileName = args[0];
- }
- else {
- fileName = PerfBase.DEFAULT_PERF_PROPERTIES_FILE_NAME;
- }
-
- return fileName;
- }
-
- protected static PerfParams getParams(final String fileName) throws Exception {
- Properties props = null;
-
- InputStream is = null;
-
- try {
- is = new FileInputStream(fileName);
-
- props = new Properties();
-
- props.load(is);
- }
- finally {
- if (is != null) {
- is.close();
- }
- }
-
- int noOfMessages = Integer.valueOf(props.getProperty("num-messages"));
- int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages"));
- int messageSize = Integer.valueOf(props.getProperty("message-size"));
- boolean durable = Boolean.valueOf(props.getProperty("durable"));
- boolean transacted = Boolean.valueOf(props.getProperty("transacted"));
- int batchSize = Integer.valueOf(props.getProperty("batch-size"));
- boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue"));
- String destinationLookup = props.getProperty("destination-lookup");
- String connectionFactoryLookup = props.getProperty("connection-factory-lookup");
- int throttleRate = Integer.valueOf(props.getProperty("throttle-rate"));
- boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
- boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
- boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
-
- PerfBase.log.info("num-messages: " + noOfMessages);
- PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages);
- PerfBase.log.info("message-size: " + messageSize);
- PerfBase.log.info("durable: " + durable);
- PerfBase.log.info("transacted: " + transacted);
- PerfBase.log.info("batch-size: " + batchSize);
- PerfBase.log.info("drain-queue: " + drainQueue);
- PerfBase.log.info("throttle-rate: " + throttleRate);
- PerfBase.log.info("connection-factory-lookup: " + connectionFactoryLookup);
- PerfBase.log.info("destination-lookup: " + destinationLookup);
- PerfBase.log.info("disable-message-id: " + disableMessageID);
- PerfBase.log.info("disable-message-timestamp: " + disableTimestamp);
- PerfBase.log.info("dups-ok-acknowledge: " + dupsOK);
-
- PerfParams perfParams = new PerfParams();
- perfParams.setNoOfMessagesToSend(noOfMessages);
- perfParams.setNoOfWarmupMessages(noOfWarmupMessages);
- perfParams.setMessageSize(messageSize);
- perfParams.setDurable(durable);
- perfParams.setSessionTransacted(transacted);
- perfParams.setBatchSize(batchSize);
- perfParams.setDrainQueue(drainQueue);
- perfParams.setConnectionFactoryLookup(connectionFactoryLookup);
- perfParams.setDestinationLookup(destinationLookup);
- perfParams.setThrottleRate(throttleRate);
- perfParams.setDisableMessageID(disableMessageID);
- perfParams.setDisableTimestamp(disableTimestamp);
- perfParams.setDupsOK(dupsOK);
-
- return perfParams;
- }
-
- private final PerfParams perfParams;
-
- protected PerfBase(final PerfParams perfParams) {
- this.perfParams = perfParams;
- }
-
- private ConnectionFactory factory;
-
- private Connection connection;
-
- private Session session;
-
- private Destination destination;
-
- private long start;
-
- private void init() throws Exception {
- InitialContext ic = new InitialContext();
- System.out.println("ic = " + ic);
- factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
-
- destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
-
- connection = factory.createConnection();
-
- session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
-
- ic.close();
- }
-
- private void displayAverage(final long numberOfMessages, final long start, final long end) {
- double duration = (1.0 * end - start) / 1000; // in seconds
- double average = 1.0 * numberOfMessages / duration;
- PerfBase.log.info(String.format("average: %.2f msg/s (%d messages in %2.2fs)", average, numberOfMessages, duration));
- }
-
- protected void runSender() {
- try {
- init();
-
- if (perfParams.isDrainQueue()) {
- drainQueue();
- }
-
- start = System.currentTimeMillis();
- PerfBase.log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages");
- sendMessages(perfParams.getNoOfWarmupMessages(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), false, perfParams.getThrottleRate(), perfParams.getMessageSize());
- PerfBase.log.info("warmed up");
- start = System.currentTimeMillis();
- sendMessages(perfParams.getNoOfMessagesToSend(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), true, perfParams.getThrottleRate(), perfParams.getMessageSize());
- long end = System.currentTimeMillis();
- displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- if (session != null) {
- try {
- session.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (connection != null) {
- try {
- connection.close();
- }
- catch (JMSException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- protected void runListener() {
- try {
- init();
-
- if (perfParams.isDrainQueue()) {
- drainQueue();
- }
-
- MessageConsumer consumer = session.createConsumer(destination);
-
- connection.start();
-
- PerfBase.log.info("READY!!!");
-
- CountDownLatch countDownLatch = new CountDownLatch(1);
- consumer.setMessageListener(new PerfListener(countDownLatch, perfParams));
- countDownLatch.await();
- long end = System.currentTimeMillis();
- // start was set on the first received message
- displayAverage(perfParams.getNoOfMessagesToSend(), start, end);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- if (session != null) {
- try {
- session.close();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- if (connection != null) {
- try {
- connection.close();
- }
- catch (JMSException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- private void drainQueue() throws Exception {
- PerfBase.log.info("Draining queue");
-
- Session drainSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer consumer = drainSession.createConsumer(destination);
-
- connection.start();
-
- Message message = null;
-
- int count = 0;
- do {
- message = consumer.receive(3000);
-
- if (message != null) {
- message.acknowledge();
-
- count++;
- }
- } while (message != null);
-
- drainSession.close();
-
- PerfBase.log.info("Drained " + count + " messages");
- }
-
- private void sendMessages(final int numberOfMessages,
- final int txBatchSize,
- final boolean durable,
- final boolean transacted,
- final boolean display,
- final int throttleRate,
- final int messageSize) throws Exception {
- MessageProducer producer = session.createProducer(destination);
-
- producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- producer.setDisableMessageID(perfParams.isDisableMessageID());
-
- producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
-
- BytesMessage message = session.createBytesMessage();
-
- byte[] payload = PerfBase.randomByteArray(messageSize);
-
- message.writeBytes(payload);
-
- final int modulo = 2000;
-
- TokenBucketLimiter tbl = throttleRate != -1 ? new TokenBucketLimiterImpl(throttleRate, false) : null;
-
- boolean committed = false;
- for (int i = 1; i <= numberOfMessages; i++) {
- producer.send(message);
-
- if (transacted) {
- if (i % txBatchSize == 0) {
- session.commit();
- committed = true;
- }
- else {
- committed = false;
- }
- }
-
- if (display && i % modulo == 0) {
- double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
- PerfBase.log.info(String.format("sent %6d messages in %2.2fs", i, duration));
- }
-
- if (tbl != null) {
- tbl.limit();
- }
- }
- if (transacted && !committed) {
- session.commit();
- }
- }
-
- private class PerfListener implements MessageListener {
-
- private final CountDownLatch countDownLatch;
-
- private final PerfParams perfParams;
-
- private boolean warmingUp = true;
-
- private boolean started = false;
-
- private final int modulo;
-
- private final AtomicLong count = new AtomicLong(0);
-
- public PerfListener(final CountDownLatch countDownLatch, final PerfParams perfParams) {
- this.countDownLatch = countDownLatch;
- this.perfParams = perfParams;
- warmingUp = perfParams.getNoOfWarmupMessages() > 0;
- modulo = 2000;
- }
-
- public void onMessage(final Message message) {
- try {
- if (warmingUp) {
- boolean committed = checkCommit();
- if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) {
- PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs");
- if (!committed) {
- checkCommit();
- }
- warmingUp = false;
- }
- return;
- }
-
- if (!started) {
- started = true;
- // reset count to take stats
- count.set(0);
- start = System.currentTimeMillis();
- }
-
- long currentCount = count.incrementAndGet();
- boolean committed = checkCommit();
- if (currentCount == perfParams.getNoOfMessagesToSend()) {
- if (!committed) {
- checkCommit();
- }
- countDownLatch.countDown();
- }
- if (currentCount % modulo == 0) {
- double duration = (1.0 * System.currentTimeMillis() - start) / 1000;
- PerfBase.log.info(String.format("received %6d messages in %2.2fs", currentCount, duration));
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private boolean checkCommit() throws Exception {
- if (perfParams.isSessionTransacted()) {
- if (count.longValue() % perfParams.getBatchSize() == 0) {
- session.commit();
-
- return true;
- }
- }
- return false;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java b/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
deleted file mode 100644
index 3f2c478..0000000
--- a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import java.util.logging.Logger;
-
-public class PerfListener extends PerfBase {
-
- private static final Logger log = Logger.getLogger(PerfListener.class.getName());
-
- public static void main(final String[] args) {
- try {
- String fileName = PerfBase.getPerfFileName(args);
-
- PerfParams params = PerfBase.getParams(fileName);
-
- new PerfListener(params).run();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private PerfListener(final PerfParams perfParams) {
- super(perfParams);
- }
-
- public void run() throws Exception {
- runListener();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java b/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
deleted file mode 100644
index c358171..0000000
--- a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import java.io.Serializable;
-
-/**
- * Class that holds the parameters used in the performance examples
- */
-public class PerfParams implements Serializable {
-
- private static final long serialVersionUID = -4336539641012356002L;
-
- private int noOfMessagesToSend = 1000;
-
- private int noOfWarmupMessages;
-
- private int messageSize = 1024; // in bytes
-
- private boolean durable = false;
-
- private boolean isSessionTransacted = false;
-
- private int batchSize = 5000;
-
- private boolean drainQueue = true;
-
- private String connectionFactoryLookup;
-
- private String destinationLookup;
-
- private int throttleRate;
-
- private boolean disableMessageID;
-
- private boolean disableTimestamp;
-
- private boolean dupsOK;
-
- public synchronized int getNoOfMessagesToSend() {
- return noOfMessagesToSend;
- }
-
- public synchronized void setNoOfMessagesToSend(final int noOfMessagesToSend) {
- this.noOfMessagesToSend = noOfMessagesToSend;
- }
-
- public synchronized int getNoOfWarmupMessages() {
- return noOfWarmupMessages;
- }
-
- public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) {
- this.noOfWarmupMessages = noOfWarmupMessages;
- }
-
- public synchronized int getMessageSize() {
- return messageSize;
- }
-
- public synchronized void setMessageSize(final int messageSize) {
- this.messageSize = messageSize;
- }
-
- public synchronized boolean isDurable() {
- return durable;
- }
-
- public synchronized void setDurable(final boolean durable) {
- this.durable = durable;
- }
-
- public synchronized boolean isSessionTransacted() {
- return isSessionTransacted;
- }
-
- public synchronized void setSessionTransacted(final boolean isSessionTransacted) {
- this.isSessionTransacted = isSessionTransacted;
- }
-
- public synchronized int getBatchSize() {
- return batchSize;
- }
-
- public synchronized void setBatchSize(final int batchSize) {
- this.batchSize = batchSize;
- }
-
- public synchronized boolean isDrainQueue() {
- return drainQueue;
- }
-
- public synchronized void setDrainQueue(final boolean drainQueue) {
- this.drainQueue = drainQueue;
- }
-
- public synchronized String getConnectionFactoryLookup() {
- return connectionFactoryLookup;
- }
-
- public synchronized void setConnectionFactoryLookup(final String connectionFactoryLookup) {
- this.connectionFactoryLookup = connectionFactoryLookup;
- }
-
- public synchronized String getDestinationLookup() {
- return destinationLookup;
- }
-
- public synchronized void setDestinationLookup(final String destinationLookup) {
- this.destinationLookup = destinationLookup;
- }
-
- public synchronized int getThrottleRate() {
- return throttleRate;
- }
-
- public synchronized void setThrottleRate(final int throttleRate) {
- this.throttleRate = throttleRate;
- }
-
- public synchronized boolean isDisableMessageID() {
- return disableMessageID;
- }
-
- public synchronized void setDisableMessageID(final boolean disableMessageID) {
- this.disableMessageID = disableMessageID;
- }
-
- public synchronized boolean isDisableTimestamp() {
- return disableTimestamp;
- }
-
- public synchronized void setDisableTimestamp(final boolean disableTimestamp) {
- this.disableTimestamp = disableTimestamp;
- }
-
- public synchronized boolean isDupsOK() {
- return dupsOK;
- }
-
- public synchronized void setDupsOK(final boolean dupsOK) {
- this.dupsOK = dupsOK;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java b/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
deleted file mode 100644
index 6649bfa..0000000
--- a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import java.util.logging.Logger;
-
-public class PerfSender extends PerfBase {
-
- private static final Logger log = Logger.getLogger(PerfSender.class.getName());
-
- public static void main(final String[] args) {
- try {
- String fileName = PerfBase.getPerfFileName(args);
-
- PerfParams params = PerfBase.getParams(fileName);
-
- new PerfSender(params).run();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private PerfSender(final PerfParams perfParams) {
- super(perfParams);
- }
-
- public void run() throws Exception {
- runSender();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java b/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
deleted file mode 100644
index 33ccd0e..0000000
--- a/examples/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.activemq.artemis.jms.example;
-
-public class Server {
-
- public static void main(String[] arg) {
- System.out.println("***********************************************************************************");
- System.out.println("You need to start manually under ./target/server/bin just run ./artemis run");
- System.out.println("***********************************************************************************");
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/resources/activemq/server0/broker.xml b/examples/perf/perf/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index a642ac5..0000000
--- a/examples/perf/perf/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version='1.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.
--->
-
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="urn:activemq"
- xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
-
- <jms xmlns="urn:activemq:jms">
- <queue name="perfQueue"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <security-enabled>false</security-enabled>
- <persistence-enabled>true</persistence-enabled>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor>
- </acceptors>
-
- <queues>
- <queue name="perfQueue">
- <address>perfAddress</address>
- </queue>
- </queues>
-
- </core>
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/resources/jndi.properties b/examples/perf/perf/src/main/resources/jndi.properties
deleted file mode 100644
index bcf6926..0000000
--- a/examples/perf/perf/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616?tcp-no-delay=false&tcp-send-buffer-size=1048576&tcp-receive-buffer-size=1048576
-queue.perfQueue=perfQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/perf/src/main/resources/perf.properties
----------------------------------------------------------------------
diff --git a/examples/perf/perf/src/main/resources/perf.properties b/examples/perf/perf/src/main/resources/perf.properties
deleted file mode 100644
index f5ca7be..0000000
--- a/examples/perf/perf/src/main/resources/perf.properties
+++ /dev/null
@@ -1,30 +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.
-
-num-messages=100000
-num-warmup-messages=1000
-message-size=1024
-durable=false
-transacted=false
-batch-size=1000
-drain-queue=false
-destination-lookup=perfQueue
-connection-factory-lookup=ConnectionFactory
-throttle-rate=-1
-dups-ok-acknowledge=false
-disable-message-id=true
-disable-message-timestamp=true
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/perf/pom.xml b/examples/perf/pom.xml
deleted file mode 100644
index afbc7ff..0000000
--- a/examples/perf/pom.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples</groupId>
- <artifactId>artemis-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>perf-root</artifactId>
- <packaging>pom</packaging>
- <name>ActiveMQ Artemis Performance Examples</name>
-
- <!-- Properties -->
- <properties>
- <!--
- Explicitly declaring the source encoding eliminates the following
- message: [WARNING] Using platform encoding (UTF-8 actually) to copy
- filtered resources, i.e. build is platform dependent!
- -->
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <activemq.basedir>${project.basedir}/../..</activemq.basedir>
- </properties>
-
- <modules>
- <module>perf</module>
- <module>soak</module>
- </modules>
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/README
----------------------------------------------------------------------
diff --git a/examples/perf/soak/README b/examples/perf/soak/README
deleted file mode 100644
index b69a1ac..0000000
--- a/examples/perf/soak/README
+++ /dev/null
@@ -1,85 +0,0 @@
-****************************************************
-* Soak Test For Manual Reconnection of JMS Clients *
-****************************************************
-
-Running the Soak Tests
-=======================
-
-Run The Server Standalone
-==========================
-
-Use the Profile server
- mvn -Pserver verify
-
-That will create a server under ./target/server0
-
-
-You can define the property server.dir under the same Profile to create other servers. or you could do it manually if desired using the regular ./artemis create
-
- $ mvn -Dserver.dir=server1 -Pserver verify
-
-server1 should contain a copy of configuration equivalent to that found under the server0 director with different
-settings.
-
-To run a server with the same configuration but on a different host. Check out this source on the host machine and
-change:
-* activemq.remoting.netty.host property in broker.xml
-* bindAddress and rmiBindAddress properties in activemq-beans.xml
-
- $ mvn verify -P server
-
-
-To run the server just start it manually
-
-Configure Server Dump
-=====================
-
-The server can "dump" info at regular interval. In broker.xml, set
-
- <server-dump-interval>10000</server-dump-interval>
-
-to have infos every 10s:
-
-**** Server Dump ****
-date: Mon Aug 17 18:19:07 CEST 2009
-free memory: 500,79 MiB
-max memory: 1,95 GiB
-total memory: 507,13 MiB
-available memory: 99,68%
-total paging memory: 0,00 B
-# of thread: 19
-# of conns: 0
-********************
-
-Run The Clients
-===============
-
-The clients can be run separate from the server using:
-
- $ mvn verify -Premote
-
-Parameters are specified in soak.properties.
-
-The duration of the tests is configured by duration-in-minutes (defaults to 2 minutes, set to
--1 to run the test indefinitely).
-
-To configure the soak properties different to the defaults for the clients, use the system property
-To specify the JNDI server to connect to, use the system property jndi.address
-
- $ mvn verify -Premote -Dsoak.props=<path to properties> -Pjndi.address=jnp:remote.host:1099
-
-Every 1000th message, the clients will display their recent activity:
-
-INFO: received 10000 messages in 5,71s (total: 55s)
-
-At the end of the run, the sender and receiver will sum up their activity:
-
-INFO: Received 223364 messages in 2,01 minutes
-
-Kill The Server And Check Manual Reconnection
-==============================================
-
-You can kill the server (ctl+c or kill -9), the clients are configured to reconnect
-indefinitely to the same single server (even in case of clean shutdown)
-Once the server restarts, all the clients will resume their activities after reconnecting
-to the server.
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/pom.xml
----------------------------------------------------------------------
diff --git a/examples/perf/soak/pom.xml b/examples/perf/soak/pom.xml
deleted file mode 100644
index 1f0757a..0000000
--- a/examples/perf/soak/pom.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-<?xml version='1.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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>artemis-jms-soak-example</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis Soak Normal Example</name>
-
- <parent>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>perf-root</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <properties>
- <server.dir>${basedir}/server0/</server.dir>
- <activemq.basedir>${project.basedir}/../../..</activemq.basedir>
- </properties>
-
- <profiles>
- <profile>
- <id>server</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <instance>${basedir}/target/server0</instance>
- <configuration>${basedir}/server0</configuration>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>artemis-jms-soak-example</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>local</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>runConsumer</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakReceiver</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>runProducer</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakSender</clientClass>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>artemis-jms-soak-example</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>remote</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>runConsumer</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakReceiver</clientClass>
- <args>
- <param>tcp://localhost:61616</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>runProducer</id>
- <goals>
- <goal>runClient</goal>
- </goals>
- <configuration>
- <clientClass>org.apache.activemq.artemis.jms.soak.example.SoakSender</clientClass>
- <args>
- <param>tcp://localhost:61616</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.soak</groupId>
- <artifactId>artemis-jms-soak-example</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/perf/soak/server0/broker.xml b/examples/perf/soak/server0/broker.xml
deleted file mode 100644
index 76df21f..0000000
--- a/examples/perf/soak/server0/broker.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version='1.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.
--->
-<configuration xmlns="urn:activemq"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
- <jms xmlns="urn:activemq:jms">
- <queue name="soakQueue"/>
- </jms>
- <core xmlns="urn:activemq:core">
- <connectors>
- <connector name="netty-connector">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</connector>
- </connectors>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576</acceptor>
- </acceptors>
-
- <security-enabled>false</security-enabled>
-
- <persistence-enabled>false</persistence-enabled>
-
- <server-dump-interval>30000</server-dump-interval>
-
- <queues>
- <queue name="soakQueue">
- <address>soakAddress</address>
- </queue>
- </queues>
- </core>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/soak.properties
----------------------------------------------------------------------
diff --git a/examples/perf/soak/soak.properties b/examples/perf/soak/soak.properties
deleted file mode 100644
index 2ccff7d..0000000
--- a/examples/perf/soak/soak.properties
+++ /dev/null
@@ -1,30 +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.
-
-duration-in-minutes=2
-num-warmup-messages=100
-message-size=1024
-durable=true
-transacted=false
-batch-size=1000
-drain-queue=false
-destination-lookup=soakQueue
-connection-factory-lookup=/ConnectionFactory
-throttle-rate=-1
-dups-ok-acknowledge=false
-disable-message-id=true
-disable-message-timestamp=true
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
----------------------------------------------------------------------
diff --git a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java b/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
deleted file mode 100644
index ce5b9bc..0000000
--- a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.soak.example;
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.Random;
-import java.util.logging.Logger;
-
-public class SoakBase {
-
- private static final Logger log = Logger.getLogger(SoakBase.class.getName());
-
- private static final String DEFAULT_SOAK_PROPERTIES_FILE_NAME = "soak.properties";
-
- public static final int TO_MILLIS = 60 * 1000; // from minute to milliseconds
-
- public static byte[] randomByteArray(final int length) {
- byte[] bytes = new byte[length];
-
- Random random = new Random();
-
- for (int i = 0; i < length; i++) {
- bytes[i] = Integer.valueOf(random.nextInt()).byteValue();
- }
-
- return bytes;
- }
-
- protected static String getPerfFileName() {
- String fileName = System.getProperty("soak.props");
- if (fileName == null) {
- fileName = SoakBase.DEFAULT_SOAK_PROPERTIES_FILE_NAME;
- }
- return fileName;
- }
-
- protected static SoakParams getParams(final String fileName) throws Exception {
- Properties props = null;
-
- InputStream is = null;
-
- try {
- is = new FileInputStream(fileName);
-
- props = new Properties();
-
- props.load(is);
- }
- finally {
- if (is != null) {
- is.close();
- }
- }
-
- int durationInMinutes = Integer.valueOf(props.getProperty("duration-in-minutes"));
- int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages"));
- int messageSize = Integer.valueOf(props.getProperty("message-size"));
- boolean durable = Boolean.valueOf(props.getProperty("durable"));
- boolean transacted = Boolean.valueOf(props.getProperty("transacted"));
- int batchSize = Integer.valueOf(props.getProperty("batch-size"));
- boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue"));
- String destinationLookup = props.getProperty("destination-lookup");
- String connectionFactoryLookup = props.getProperty("connection-factory-lookup");
- int throttleRate = Integer.valueOf(props.getProperty("throttle-rate"));
- boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege"));
- boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id"));
- boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp"));
-
- SoakBase.log.info("duration-in-minutes: " + durationInMinutes);
- SoakBase.log.info("num-warmup-messages: " + noOfWarmupMessages);
- SoakBase.log.info("message-size: " + messageSize);
- SoakBase.log.info("durable: " + durable);
- SoakBase.log.info("transacted: " + transacted);
- SoakBase.log.info("batch-size: " + batchSize);
- SoakBase.log.info("drain-queue: " + drainQueue);
- SoakBase.log.info("throttle-rate: " + throttleRate);
- SoakBase.log.info("connection-factory-lookup: " + connectionFactoryLookup);
- SoakBase.log.info("destination-lookup: " + destinationLookup);
- SoakBase.log.info("disable-message-id: " + disableMessageID);
- SoakBase.log.info("disable-message-timestamp: " + disableTimestamp);
- SoakBase.log.info("dups-ok-acknowledge: " + dupsOK);
-
- SoakParams soakParams = new SoakParams();
- soakParams.setDurationInMinutes(durationInMinutes);
- soakParams.setNoOfWarmupMessages(noOfWarmupMessages);
- soakParams.setMessageSize(messageSize);
- soakParams.setDurable(durable);
- soakParams.setSessionTransacted(transacted);
- soakParams.setBatchSize(batchSize);
- soakParams.setDrainQueue(drainQueue);
- soakParams.setConnectionFactoryLookup(connectionFactoryLookup);
- soakParams.setDestinationLookup(destinationLookup);
- soakParams.setThrottleRate(throttleRate);
- soakParams.setDisableMessageID(disableMessageID);
- soakParams.setDisableTimestamp(disableTimestamp);
- soakParams.setDupsOK(dupsOK);
-
- return soakParams;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
----------------------------------------------------------------------
diff --git a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java b/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
deleted file mode 100644
index dda2ac1..0000000
--- a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.soak.example;
-
-import java.io.Serializable;
-
-/**
- * Class that holds the parameters used in the performance examples
- */
-public class SoakParams implements Serializable {
-
- private static final long serialVersionUID = -4336539641012356002L;
-
- private int durationInMinutes = 60;
-
- private int noOfWarmupMessages;
-
- private int messageSize = 1024; // in bytes
-
- private boolean durable = false;
-
- private boolean isSessionTransacted = false;
-
- private int batchSize = 5000;
-
- private boolean drainQueue = true;
-
- private String connectionFactoryLookup;
-
- private String destinationLookup;
-
- private int throttleRate;
-
- private boolean disableMessageID;
-
- private boolean disableTimestamp;
-
- private boolean dupsOK;
-
- public synchronized int getDurationInMinutes() {
- return durationInMinutes;
- }
-
- public synchronized void setDurationInMinutes(final int durationInMinutes) {
- this.durationInMinutes = durationInMinutes;
- }
-
- public synchronized int getNoOfWarmupMessages() {
- return noOfWarmupMessages;
- }
-
- public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) {
- this.noOfWarmupMessages = noOfWarmupMessages;
- }
-
- public synchronized int getMessageSize() {
- return messageSize;
- }
-
- public synchronized void setMessageSize(final int messageSize) {
- this.messageSize = messageSize;
- }
-
- public synchronized boolean isDurable() {
- return durable;
- }
-
- public synchronized void setDurable(final boolean durable) {
- this.durable = durable;
- }
-
- public synchronized boolean isSessionTransacted() {
- return isSessionTransacted;
- }
-
- public synchronized void setSessionTransacted(final boolean isSessionTransacted) {
- this.isSessionTransacted = isSessionTransacted;
- }
-
- public synchronized int getBatchSize() {
- return batchSize;
- }
-
- public synchronized void setBatchSize(final int batchSize) {
- this.batchSize = batchSize;
- }
-
- public synchronized boolean isDrainQueue() {
- return drainQueue;
- }
-
- public synchronized void setDrainQueue(final boolean drainQueue) {
- this.drainQueue = drainQueue;
- }
-
- public synchronized String getConnectionFactoryLookup() {
- return connectionFactoryLookup;
- }
-
- public synchronized void setConnectionFactoryLookup(final String connectionFactoryLookup) {
- this.connectionFactoryLookup = connectionFactoryLookup;
- }
-
- public synchronized String getDestinationLookup() {
- return destinationLookup;
- }
-
- public synchronized void setDestinationLookup(final String destinationLookup) {
- this.destinationLookup = destinationLookup;
- }
-
- public synchronized int getThrottleRate() {
- return throttleRate;
- }
-
- public synchronized void setThrottleRate(final int throttleRate) {
- this.throttleRate = throttleRate;
- }
-
- public synchronized boolean isDisableMessageID() {
- return disableMessageID;
- }
-
- public synchronized void setDisableMessageID(final boolean disableMessageID) {
- this.disableMessageID = disableMessageID;
- }
-
- public synchronized boolean isDisableTimestamp() {
- return disableTimestamp;
- }
-
- public synchronized void setDisableTimestamp(final boolean disableTimestamp) {
- this.disableTimestamp = disableTimestamp;
- }
-
- public synchronized boolean isDupsOK() {
- return dupsOK;
- }
-
- public synchronized void setDupsOK(final boolean dupsOK) {
- this.dupsOK = dupsOK;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
----------------------------------------------------------------------
diff --git a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java b/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
deleted file mode 100644
index ce39968..0000000
--- a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.soak.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-public class SoakReceiver {
-
- private static final Logger log = Logger.getLogger(SoakReceiver.class.getName());
-
- private static final String EOF = UUID.randomUUID().toString();
-
- public static void main(final String[] args) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
-
- try {
- String fileName = SoakBase.getPerfFileName();
-
- SoakParams params = SoakBase.getParams(fileName);
-
- final SoakReceiver receiver = new SoakReceiver(params);
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- receiver.disconnect();
- }
- });
-
- receiver.run();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
-
- Thread t = new Thread(runnable);
- t.start();
- }
-
- private final SoakParams perfParams;
-
- private final ExceptionListener exceptionListener = new ExceptionListener() {
- public void onException(final JMSException e) {
- disconnect();
- connect();
- }
- };
-
- private final MessageListener listener = new MessageListener() {
- int modulo = 10000;
-
- private final AtomicLong count = new AtomicLong(0);
-
- private final long start = System.currentTimeMillis();
-
- long moduloStart = start;
-
- public void onMessage(final Message msg) {
- long totalDuration = System.currentTimeMillis() - start;
-
- try {
- if (SoakReceiver.EOF.equals(msg.getStringProperty("eof"))) {
- SoakReceiver.log.info(String.format("Received %s messages in %.2f minutes", count, 1.0 * totalDuration / SoakBase.TO_MILLIS));
- SoakReceiver.log.info("END OF RUN");
-
- return;
- }
- }
- catch (JMSException e1) {
- e1.printStackTrace();
- }
- if (count.incrementAndGet() % modulo == 0) {
- double duration = (1.0 * System.currentTimeMillis() - moduloStart) / 1000;
- moduloStart = System.currentTimeMillis();
- SoakReceiver.log.info(String.format("received %s messages in %2.2fs (total: %.0fs)", modulo, duration, totalDuration / 1000.0));
- }
- }
- };
-
- private Session session;
-
- private Connection connection;
-
- private SoakReceiver(final SoakParams perfParams) {
- this.perfParams = perfParams;
- }
-
- public void run() throws Exception {
- connect();
-
- boolean runInfinitely = perfParams.getDurationInMinutes() == -1;
-
- if (!runInfinitely) {
- Thread.sleep(perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS);
-
- // send EOF message
- Message eof = session.createMessage();
- eof.setStringProperty("eof", SoakReceiver.EOF);
- listener.onMessage(eof);
-
- if (connection != null) {
- connection.close();
- connection = null;
- }
- }
- else {
- while (true) {
- Thread.sleep(500);
- }
- }
- }
-
- private void disconnect() {
- if (connection != null) {
- try {
- connection.setExceptionListener(null);
- connection.close();
- }
- catch (JMSException e) {
- e.printStackTrace();
- }
- finally {
- connection = null;
- }
- }
- }
-
- private void connect() {
- InitialContext ic = null;
- try {
- ic = new InitialContext();
-
- ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
-
- Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
-
- connection = factory.createConnection();
- connection.setExceptionListener(exceptionListener);
-
- session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer messageConsumer = session.createConsumer(destination);
- messageConsumer.setMessageListener(listener);
-
- connection.start();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- try {
- ic.close();
- }
- catch (NamingException e) {
- e.printStackTrace();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
----------------------------------------------------------------------
diff --git a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java b/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
deleted file mode 100644
index 10fbbd8..0000000
--- a/examples/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.soak.example;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-import org.apache.activemq.artemis.utils.TokenBucketLimiter;
-import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl;
-
-public class SoakSender {
-
- private static final Logger log = Logger.getLogger(SoakSender.class.getName());
-
- public static void main(final String[] args) {
- try {
- String fileName = SoakBase.getPerfFileName();
-
- SoakParams params = SoakBase.getParams(fileName);
- final SoakSender sender = new SoakSender(params);
-
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- sender.disconnect();
- }
- });
-
- sender.run();
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private final SoakParams perfParams;
-
- private Connection connection;
-
- private Session session;
-
- private MessageProducer producer;
-
- private final ExceptionListener exceptionListener = new ExceptionListener() {
- public void onException(final JMSException e) {
- System.out.println("SoakReconnectableSender.exceptionListener.new ExceptionListener() {...}.onException()");
- disconnect();
- connect();
- }
-
- };
-
- private SoakSender(final SoakParams perfParams) {
- this.perfParams = perfParams;
- }
-
- public void run() throws Exception {
- connect();
-
- boolean runInfinitely = perfParams.getDurationInMinutes() == -1;
-
- BytesMessage message = session.createBytesMessage();
-
- byte[] payload = SoakBase.randomByteArray(perfParams.getMessageSize());
-
- message.writeBytes(payload);
-
- final int modulo = 10000;
-
- TokenBucketLimiter tbl = perfParams.getThrottleRate() != -1 ? new TokenBucketLimiterImpl(perfParams.getThrottleRate(), false) : null;
-
- boolean transacted = perfParams.isSessionTransacted();
- int txBatchSize = perfParams.getBatchSize();
- boolean display = true;
-
- long start = System.currentTimeMillis();
- long moduleStart = start;
- AtomicLong count = new AtomicLong(0);
- while (true) {
- try {
- producer.send(message);
- count.incrementAndGet();
-
- if (transacted) {
- if (count.longValue() % txBatchSize == 0) {
- session.commit();
- }
- }
-
- long totalDuration = System.currentTimeMillis() - start;
-
- if (display && count.longValue() % modulo == 0) {
- double duration = (1.0 * System.currentTimeMillis() - moduleStart) / 1000;
- moduleStart = System.currentTimeMillis();
- SoakSender.log.info(String.format("sent %s messages in %2.2fs (time: %.0fs)", modulo, duration, totalDuration / 1000.0));
- }
-
- if (tbl != null) {
- tbl.limit();
- }
-
- if (!runInfinitely && totalDuration > perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS) {
- break;
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- SoakSender.log.info(String.format("Sent %s messages in %s minutes", count, perfParams.getDurationInMinutes()));
- SoakSender.log.info("END OF RUN");
-
- if (connection != null) {
- connection.close();
- connection = null;
- }
- }
-
- private synchronized void disconnect() {
- if (connection != null) {
- try {
- connection.setExceptionListener(null);
- connection.close();
- }
- catch (JMSException e) {
- e.printStackTrace();
- }
- finally {
- connection = null;
- }
- }
- }
-
- private void connect() {
- InitialContext ic = null;
- try {
- ic = new InitialContext();
-
- ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup());
-
- Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup());
-
- connection = factory.createConnection();
-
- session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE);
-
- producer = session.createProducer(destination);
-
- producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- producer.setDisableMessageID(perfParams.isDisableMessageID());
-
- producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp());
-
- connection.setExceptionListener(exceptionListener);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- finally {
- try {
- ic.close();
- }
- catch (NamingException e) {
- e.printStackTrace();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/perf/soak/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/perf/soak/src/main/resources/jndi.properties b/examples/perf/soak/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/perf/soak/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +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.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/amqp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/amqp/pom.xml b/examples/protocols/amqp/pom.xml
index d40adb2..d2f5d06 100644
--- a/examples/protocols/amqp/pom.xml
+++ b/examples/protocols/amqp/pom.xml
@@ -45,7 +45,7 @@ under the License.
<profiles>
<profile>
- <id>examples</id>
+ <id>release</id>
<modules>
<module>proton-cpp</module>
<module>proton-j</module>
@@ -53,9 +53,11 @@ under the License.
</modules>
</profile>
<profile>
- <id>release</id>
+ <id>examples</id>
<modules>
- <module>proton-cpp</module>
+ <!-- this one to be run manually
+ <module>proton-cpp</module> -->
+
<module>proton-j</module>
<module>proton-ruby</module>
</modules>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java
index 310ba54..e92e0b6 100644
--- a/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java
+++ b/examples/protocols/openwire/chat/src/main/java/org/apache/activemq/artemis/openwire/example/Chat.java
@@ -132,9 +132,6 @@ public class Chat implements javax.jms.MessageListener {
* Main program entry point.
*/
public static void main(String[] argv) {
-
- System.out.println("len::" + argv.length);
-
// Is there anything to do?
if (argv.length == 0) {
printUsage();
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a0cca441/examples/protocols/openwire/message-listener/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/openwire/message-listener/pom.xml b/examples/protocols/openwire/message-listener/pom.xml
new file mode 100644
index 0000000..f54c549
--- /dev/null
+++ b/examples/protocols/openwire/message-listener/pom.xml
@@ -0,0 +1,116 @@
+<?xml version='1.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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>openwire-examples</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>message-listener</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Queue Example for openwire</name>
+
+ <properties>
+ <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-client</artifactId>
+ <version>${activemq5-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>${slf4j-version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create</id>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <spawn>true</spawn>
+ <ignore>${noServer}</ignore>
+ <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.QueueExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <ignore>${noServer}</ignore>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.openwire</groupId>
+ <artifactId>message-listener</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>