activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: Adding stomp-jms example
Date Wed, 07 Oct 2015 02:06:43 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 32dacf91f -> d2a5003ff


Adding stomp-jms example


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

Branch: refs/heads/master
Commit: d2a5003ff48392490bd2d66c0977d177ae8112da
Parents: 32dacf9
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Tue Oct 6 21:19:25 2015 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Oct 6 22:05:59 2015 -0400

----------------------------------------------------------------------
 .../core/protocol/stomp/StompConnection.java    |   2 +
 examples/protocols/stomp/pom.xml                |   2 +
 examples/protocols/stomp/stomp-jms/pom.xml      | 113 +++++++++++++++++++
 examples/protocols/stomp/stomp-jms/readme.html  |  37 ++++++
 .../artemis/jms/example/StompExample.java       |  65 +++++++++++
 5 files changed, 219 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d2a5003f/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
index 61d565a..fb2d56c 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompConnection.java
@@ -460,6 +460,8 @@ public final class StompConnection implements RemotingConnection {
          stompListener.requestAccepted(request);
       }
 
+      System.out.println("Frame::" + request);
+
       String cmd = request.getCommand();
       try {
          if (isDestroyed()) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d2a5003f/examples/protocols/stomp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/pom.xml b/examples/protocols/stomp/pom.xml
index a4ccd18..5ad8232 100644
--- a/examples/protocols/stomp/pom.xml
+++ b/examples/protocols/stomp/pom.xml
@@ -48,6 +48,7 @@ under the License.
             <module>stomp-embedded-interceptor</module>
             <module>stomp1.1</module>
             <module>stomp1.2</module>
+            <module>stomp-jms</module>
          </modules>
       </profile>
       <profile>
@@ -55,6 +56,7 @@ under the License.
          <modules>
             <module>stomp</module>
             <module>stomp-embedded-interceptor</module>
+            <module>stomp-jms</module>
 
             <!-- has to be executed manually
             <module>stomp-websockets</module> -->

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d2a5003f/examples/protocols/stomp/stomp-jms/pom.xml
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-jms/pom.xml b/examples/protocols/stomp/stomp-jms/pom.xml
new file mode 100644
index 0000000..45fca77
--- /dev/null
+++ b/examples/protocols/stomp/stomp-jms/pom.xml
@@ -0,0 +1,113 @@
+<?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.stomp</groupId>
+      <artifactId>stomp-examples</artifactId>
+      <version>1.1.1-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>stomp-jms</artifactId>
+   <packaging>jar</packaging>
+   <name>ActiveMQ Artemis JMS Stomp JMS Example</name>
+
+   <properties>
+      <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
+   </properties>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.apache.activemq</groupId>
+         <artifactId>artemis-jms-client</artifactId>
+         <version>${project.version}</version>
+      </dependency>
+      <dependency>
+         <groupId>org.fusesource.stompjms</groupId>
+         <artifactId>stompjms-client</artifactId>
+         <version>1.19</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>
+                     <ignore>${noServer}</ignore>
+                     <spawn>true</spawn>
+                     <testURI>tcp://localhost:61616</testURI>
+                     <args>
+                        <param>run</param>
+                     </args>
+                  </configuration>
+               </execution>
+               <execution>
+                  <id>runClient</id>
+                  <goals>
+                     <goal>runClient</goal>
+                  </goals>
+                  <configuration>
+                     <clientClass>org.apache.activemq.artemis.jms.example.StompExample</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.stomp</groupId>
+                  <artifactId>stomp-jms</artifactId>
+                  <version>${project.version}</version>
+               </dependency>
+            </dependencies>
+         </plugin>
+      </plugins>
+   </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d2a5003f/examples/protocols/stomp/stomp-jms/readme.html
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-jms/readme.html b/examples/protocols/stomp/stomp-jms/readme.html
new file mode 100644
index 0000000..efee00d
--- /dev/null
+++ b/examples/protocols/stomp/stomp-jms/readme.html
@@ -0,0 +1,37 @@
+<!--
+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 Stomp 1.1 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>Stomp 1.2 Example</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 configure ActiveMQ Artemis to send and receive
Stomp messages using Stomp 1.2 protocol.</p>
+     <p>The example will start a ActiveMQ Artemis server configured with Stomp and
JMS.</p>
+     <p>On this example we are using  <a href="https://github.com/fusesource/stompjms">stomp-jms</a>.</p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d2a5003f/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java
----------------------------------------------------------------------
diff --git a/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java
b/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java
new file mode 100644
index 0000000..5c7b330
--- /dev/null
+++ b/examples/protocols/stomp/stomp-jms/src/main/java/org/apache/activemq/artemis/jms/example/StompExample.java
@@ -0,0 +1,65 @@
+/*
+ * 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.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.fusesource.stomp.jms.StompJmsConnectionFactory;
+
+/**
+ * An example using StompJMS.
+ */
+public class StompExample {
+
+   public static void main(final String[] args) throws Exception {
+      StompJmsConnectionFactory factory = new StompJmsConnectionFactory();
+      factory.setQueuePrefix("jms.queue.");
+      factory.setDisconnectTimeout(5000);
+      factory.setTopicPrefix("jms.topic.");
+      factory.setBrokerURI("tcp://localhost:61616");
+      Connection connection = factory.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Queue queue = session.createQueue("queue1");
+      MessageProducer producer = session.createProducer(queue);
+
+      producer.send(session.createTextMessage("Hello"));
+
+      connection.start();
+
+
+      System.out.println("Waiting 20 seconds");
+      Thread.sleep(10000); // increase this and it will fail
+      System.out.println("waited");
+
+      MessageConsumer consumer = session.createConsumer(queue);
+
+      TextMessage message = (TextMessage) consumer.receive(5000);
+
+      System.out.println("The content of the message is " + message.getText());
+
+      if (!message.getText().equals("Hello")) {
+         throw new IllegalStateException("the content of the message was different than expected!");
+      }
+
+      connection.close();
+   }
+}


Mime
View raw message