You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2022/02/01 11:12:48 UTC

[tomee] branch master updated: TOMEE-3833 simple example for websockets and JMS

This is an automated email from the ASF dual-hosted git repository.

jgallimore pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new 301bfb4  TOMEE-3833 simple example for websockets and JMS
     new f1e7dba  Merge remote-tracking branch 'apache/master'
301bfb4 is described below

commit 301bfb412d94cbecd29bb19da20d8430cb378c30
Author: Jonathan Gallimore <jo...@jrg.me.uk>
AuthorDate: Tue Feb 1 11:11:48 2022 +0000

    TOMEE-3833 simple example for websockets and JMS
---
 .../tests/jaxws/WebServiceContextEJBTest.java      |   3 -
 examples/pom.xml                                   |   1 +
 examples/websocket-jms/README.adoc                 |   8 +
 examples/websocket-jms/build.xml                   | 119 +++++++++++++++
 examples/websocket-jms/pom.xml                     | 167 +++++++++++++++++++++
 .../superbiz/websockets/MessageReceivedEvent.java  |  31 ++++
 .../org/superbiz/websockets/MessageReceiver.java   |  51 +++++++
 .../org/superbiz/websockets/MessageSender.java     |  58 +++++++
 .../org/superbiz/websockets/WebSocketResource.java |  75 +++++++++
 .../src/main/webapp/WEB-INF/beans.xml              |  20 +++
 .../websocket-jms/src/main/webapp/WEB-INF/web.xml  |  26 ++++
 examples/websocket-jms/src/main/webapp/index.html  | 137 +++++++++++++++++
 examples/websocket-jms/src/test/config/tomee.xml   |  41 +++++
 .../src/test/resources/arquillian.xml              |  30 ++++
 14 files changed, 764 insertions(+), 3 deletions(-)

diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/WebServiceContextEJBTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/WebServiceContextEJBTest.java
index 706a178..df18bb6 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/WebServiceContextEJBTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxws-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxws/WebServiceContextEJBTest.java
@@ -151,9 +151,6 @@ public class WebServiceContextEJBTest {
         @Resource
         private WebServiceContext context;
 
-        @Inject
-        private HttpServletRequest httpServletRequest;
-
         @WebMethod
         public String sayHello(final @WebParam(name="name") String name) {
 
diff --git a/examples/pom.xml b/examples/pom.xml
index 9514e38..87d988d 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -217,6 +217,7 @@
     <module>cloud-tomee-azure</module>
     <module>mp-faulttolerance-timeout</module>
     <module>xa-datasource</module>
+    <module>websocket-jms</module>
 
     <!-- Jakarta Security Examples -->
     <module>security-tomcat-user-identitystore</module>
diff --git a/examples/websocket-jms/README.adoc b/examples/websocket-jms/README.adoc
new file mode 100644
index 0000000..3fb7e50
--- /dev/null
+++ b/examples/websocket-jms/README.adoc
@@ -0,0 +1,8 @@
+:index-group: Websockets with JMS
+:jbake-type: page
+:jbake-status: status=published
+
+= Websocket JMS
+
+This example demonstrates a simple 'chat' application that uses Websockets and JMS.
+
diff --git a/examples/websocket-jms/build.xml b/examples/websocket-jms/build.xml
new file mode 100644
index 0000000..b93658c
--- /dev/null
+++ b/examples/websocket-jms/build.xml
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project name="MyProject" default="dist" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
+
+  <!-- ===============================================================
+
+  HOW TO RUN
+
+    Download http://archive.apache.org/dist/maven/binaries/maven-ant-tasks-2.0.9.jar
+    Then execute ant as follows:
+
+    ant -lib maven-ant-tasks-2.0.9.jar
+
+  NOTE
+
+    You do NOT need maven-ant-tasks-2.0.9.jar to use OpenEJB for embedded EJB
+    testing with Ant.  It is simply used in this example to make the build.xml
+    a bit simpler.  As long as OpenEJB and it's required libraries are in the
+    <junit> classpath, the tests will run with OpenEJB embedded.
+
+  ================================================================= -->
+
+  <artifact:remoteRepository id="apache.snapshot.repository" url="http://repository.apache.org/snapshots/"/>
+  <artifact:remoteRepository id="m2.repository" url="http://repo1.maven.org/maven2/"/>
+
+  <!-- Build Classpath -->
+  <artifact:dependencies pathId="classpath.main">
+    <dependency groupId="org.apache.openejb" artifactId="javaee-api-embedded" version="6.0-3"/>
+  </artifact:dependencies>
+
+  <!-- Test Build Classpath -->
+  <artifact:dependencies pathId="classpath.test.build">
+    <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+  </artifact:dependencies>
+
+  <!-- Test Run Classpath -->
+  <artifact:dependencies pathId="classpath.test.run">
+    <remoteRepository refid="apache.snapshot.repository"/>
+    <remoteRepository refid="m2.repository"/>
+
+    <dependency groupId="org.apache.openejb" artifactId="openejb-core" version="4.0.0-beta-1"/>
+    <dependency groupId="junit" artifactId="junit" version="4.3.1"/>
+  </artifact:dependencies>
+
+  <!-- Properties -->
+
+  <property name="src.main.java" location="src/main/java"/>
+  <property name="src.main.resources" location="src/main/resources"/>
+  <property name="src.test.java" location="src/test/java"/>
+  <property name="build.main" location="target/classes"/>
+  <property name="build.test" location="target/test-classes"/>
+  <property name="test.reports" location="target/test-reports"/>
+  <property name="dist" location="target"/>
+
+
+  <target name="init">
+    <mkdir dir="${build.main}"/>
+    <mkdir dir="${build.test}"/>
+    <mkdir dir="${test.reports}"/>
+  </target>
+
+  <target name="compile" depends="init">
+
+    <javac srcdir="${src.main.java}" destdir="${build.main}">
+      <classpath refid="classpath.main"/>
+    </javac>
+    <copy todir="${build.main}">
+      <fileset dir="${src.main.resources}"/>
+    </copy>
+
+    <javac srcdir="${src.test.java}" destdir="${build.test}">
+      <classpath location="${build.main}"/>
+      <classpath refid="classpath.main"/>
+      <classpath refid="classpath.test.build"/>
+    </javac>
+  </target>
+
+  <target name="test" depends="compile">
+    <junit fork="yes" printsummary="yes">
+      <classpath location="${build.main}"/>
+      <classpath location="${build.test}"/>
+      <classpath refid="classpath.main"/>
+      <classpath refid="classpath.test.build"/>
+      <classpath refid="classpath.test.run"/>
+
+      <formatter type="plain"/>
+
+      <batchtest fork="yes" todir="${test.reports}">
+        <fileset dir="${src.test.java}">
+          <include name="**/*Test.java"/>
+        </fileset>
+      </batchtest>
+    </junit>
+  </target>
+
+  <target name="dist" depends="test">
+    <jar jarfile="${dist}/myproject-1.0.jar" basedir="${build.main}"/>
+  </target>
+
+</project>
diff --git a/examples/websocket-jms/pom.xml b/examples/websocket-jms/pom.xml
new file mode 100644
index 0000000..e681845
--- /dev/null
+++ b/examples/websocket-jms/pom.xml
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+<!-- $Rev$ $Date$ -->
+<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>
+  <groupId>org.superbiz</groupId>
+  <artifactId>websocket-jms</artifactId>
+  <packaging>war</packaging>
+  <version>8.0.10-SNAPSHOT</version>
+  <name>TomEE :: Examples :: Websocket JMS</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <version.arquillian>1.1.13.Final</version.arquillian>
+    <tomee.version>8.0.10-SNAPSHOT</tomee.version>
+  </properties>
+  <build>
+    <finalName>websocket-jms</finalName>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.5.1</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.tomee.maven</groupId>
+        <artifactId>tomee-maven-plugin</artifactId>
+        <version>${tomee.version}</version>
+        <configuration>
+          <tomeeClassifier>plus</tomeeClassifier>
+          <args>-Xmx512m -XX:PermSize=256m</args>
+          <config>src/test/config</config>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-war-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <failOnMissingWebXml>false</failOnMissingWebXml>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.tomitribe.transformer</groupId>
+        <artifactId>org.eclipse.transformer.maven</artifactId>
+        <version>0.1.1a</version>
+        <configuration>
+          <classifier>jakartaee9</classifier>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <phase>package</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>https://repository.apache.org/content/groups/snapshots</url>
+    </repository>
+  </repositories>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>[8.0,)</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>${tomee.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>tomee-jaxrs</artifactId>
+      <version>${tomee.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+      <version>${version.arquillian}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.resolver</groupId>
+      <artifactId>shrinkwrap-resolver-api-maven</artifactId>
+      <version>2.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.resolver</groupId>
+      <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+      <version>2.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.resolver</groupId>
+      <artifactId>shrinkwrap-resolver-spi-maven</artifactId>
+      <version>2.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>arquillian-tomee-remote</artifactId>
+      <version>${tomee.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>ziplock</artifactId>
+      <version>${tomee.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>
diff --git a/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceivedEvent.java b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceivedEvent.java
new file mode 100644
index 0000000..9536683
--- /dev/null
+++ b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceivedEvent.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.superbiz.websockets;
+
+public class MessageReceivedEvent {
+
+    private final String message;
+
+    public MessageReceivedEvent(String message) {
+        this.message = message;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}
diff --git a/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceiver.java b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceiver.java
new file mode 100644
index 0000000..a8cb57a
--- /dev/null
+++ b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageReceiver.java
@@ -0,0 +1,51 @@
+/*
+ * 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.superbiz.websockets;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+import java.util.logging.Logger;
+
+@MessageDriven( activationConfig = {
+        @ActivationConfigProperty(propertyName = "destination", propertyValue = "messageReceived"),
+        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
+})
+public class MessageReceiver implements MessageListener {
+
+    private static Logger LOG = Logger.getLogger(MessageReceiver.class.getName());
+
+    @Inject
+    private Event<MessageReceivedEvent> event;
+
+    @Override
+    public void onMessage(final Message message) {
+        if (message instanceof TextMessage) {
+            try {
+                event.fire(new MessageReceivedEvent(TextMessage.class.cast(message).getText()));
+            } catch (JMSException e) {
+                LOG.warning("Error processing JMS message: " + e.getMessage());
+            }
+        }
+    }
+}
diff --git a/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageSender.java b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageSender.java
new file mode 100644
index 0000000..6b0da49
--- /dev/null
+++ b/examples/websocket-jms/src/main/java/org/superbiz/websockets/MessageSender.java
@@ -0,0 +1,58 @@
+/*
+ * 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.superbiz.websockets;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.Resource;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.inject.Inject;
+import javax.jms.JMSContext;
+import javax.jms.Topic;
+import java.util.logging.Logger;
+
+@Singleton
+@Startup
+@Lock(LockType.READ)
+public class MessageSender {
+
+    private static final Logger LOG = Logger.getLogger(MessageSender.class.getName());
+
+    @Inject
+    private JMSContext jmsContext;
+
+    @Resource(name = "messageReceived")
+    private Topic messageReceived;
+
+    @PostConstruct
+    public void postConstruct() {
+        LOG.info("Message sender started");
+    }
+
+    @PreDestroy
+    public void preDestroy() {
+        LOG.info("Message sender stopped");
+    }
+
+    public void send(final String message) {
+        jmsContext.createProducer().send(messageReceived, message);
+    }
+}
diff --git a/examples/websocket-jms/src/main/java/org/superbiz/websockets/WebSocketResource.java b/examples/websocket-jms/src/main/java/org/superbiz/websockets/WebSocketResource.java
new file mode 100644
index 0000000..6b9dfef
--- /dev/null
+++ b/examples/websocket-jms/src/main/java/org/superbiz/websockets/WebSocketResource.java
@@ -0,0 +1,75 @@
+/*
+ * 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.superbiz.websockets;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
+import javax.websocket.Session;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Logger;
+
+@ServerEndpoint("/chat")
+@ApplicationScoped
+public class WebSocketResource {
+
+    @Inject
+    private MessageSender messageSender;
+
+    private static final Logger LOG = Logger.getLogger(WebSocketResource.class.getName());
+    private static final Set<Session> SESSIONS = Collections.synchronizedSet(new HashSet<>());
+
+
+    @OnOpen
+    public void onOpen(final Session session) throws Exception {
+        SESSIONS.add(session);
+    }
+
+    @OnClose
+    public void onClose(final Session session) throws IOException {
+        SESSIONS.remove(session);
+    }
+
+    @OnMessage
+    public void onMessage(final String message, final Session session) {
+        messageSender.send(message);
+    }
+
+    @OnError
+    public void onError(final Session session, final Throwable throwable) {
+        LOG.warning("websocket error: " + throwable.getMessage());
+    }
+
+    public void broadcast(final @Observes MessageReceivedEvent event) {
+        SESSIONS.forEach(s -> {
+            try {
+                s.getBasicRemote().sendText(event.getMessage());
+            } catch (IOException e) {
+                LOG.warning("Error sending websocket message: " + e.getMessage());
+            }
+        });
+    }
+}
diff --git a/examples/websocket-jms/src/main/webapp/WEB-INF/beans.xml b/examples/websocket-jms/src/main/webapp/WEB-INF/beans.xml
new file mode 100644
index 0000000..339c763
--- /dev/null
+++ b/examples/websocket-jms/src/main/webapp/WEB-INF/beans.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  ~ Copyright 2016 Microprofile.io
+  ~
+  ~ Licensed 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.
+  -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+       bean-discovery-mode="annotated" version="1.1"
+       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"/>
diff --git a/examples/websocket-jms/src/main/webapp/WEB-INF/web.xml b/examples/websocket-jms/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..2e36a6a
--- /dev/null
+++ b/examples/websocket-jms/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+  ~ Licensed 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.
+  -->
+<web-app version="3.1"
+         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="
+          http://xmlns.jcp.org/xml/ns/javaee
+          http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
+
+    <welcome-file-list>
+        <welcome-file>index.html</welcome-file>
+    </welcome-file-list>
+
+</web-app>
diff --git a/examples/websocket-jms/src/main/webapp/index.html b/examples/websocket-jms/src/main/webapp/index.html
new file mode 100644
index 0000000..07716c5
--- /dev/null
+++ b/examples/websocket-jms/src/main/webapp/index.html
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Apache Tomcat WebSocket Examples: Chat</title>
+    <style type="text/css">
+        input#chat {
+        width: 410px
+    }
+
+    #console-container {
+        width: 400px;
+    }
+
+    #console {
+        border: 1px solid #CCCCCC;
+        border-right-color: #999999;
+        border-bottom-color: #999999;
+        height: 170px;
+        overflow-y: scroll;
+        padding: 5px;
+        width: 100%;
+    }
+
+    #console p {
+        padding: 0;
+        margin: 0;
+    }
+    </style>
+    <script type="application/javascript">
+    "use strict";
+
+    var Chat = {};
+
+    Chat.socket = null;
+
+    Chat.connect = (function(host) {
+        if ('WebSocket' in window) {
+            Chat.socket = new WebSocket(host);
+        } else if ('MozWebSocket' in window) {
+            Chat.socket = new MozWebSocket(host);
+        } else {
+            Console.log('Error: WebSocket is not supported by this browser.');
+            return;
+        }
+
+        Chat.socket.onopen = function () {
+            Console.log('Info: WebSocket connection opened.');
+            document.getElementById('chat').onkeydown = function(event) {
+                if (event.keyCode == 13) {
+                    Chat.sendMessage();
+                }
+            };
+        };
+
+        Chat.socket.onclose = function () {
+            document.getElementById('chat').onkeydown = null;
+            Console.log('Info: WebSocket closed.');
+        };
+
+        Chat.socket.onmessage = function (message) {
+            Console.log(message.data);
+        };
+    });
+
+    Chat.initialize = function() {
+        if (window.location.protocol == 'http:') {
+            Chat.connect('ws://' + window.location.host + '/websocket-jms/chat');
+        } else {
+            Chat.connect('wss://' + window.location.host + '/websocket-jms/chat');
+        }
+    };
+
+    Chat.sendMessage = (function() {
+        var message = document.getElementById('chat').value;
+        if (message != '') {
+            Chat.socket.send(message);
+            document.getElementById('chat').value = '';
+        }
+    });
+
+    var Console = {};
+
+    Console.log = (function(message) {
+        var console = document.getElementById('console');
+        var p = document.createElement('p');
+        p.style.wordWrap = 'break-word';
+        p.innerHTML = message;
+        console.appendChild(p);
+        while (console.childNodes.length > 25) {
+            console.removeChild(console.firstChild);
+        }
+        console.scrollTop = console.scrollHeight;
+    });
+
+    Chat.initialize();
+
+
+    document.addEventListener("DOMContentLoaded", function() {
+        // Remove elements with "noscript" class - <noscript> is not allowed in XHTML
+        var noscripts = document.getElementsByClassName("noscript");
+        for (var i = 0; i < noscripts.length; i++) {
+            noscripts[i].parentNode.removeChild(noscripts[i]);
+        }
+    }, false);
+
+    </script>
+</head>
+<body>
+<div class="noscript"><h2 style="color: #ff0000">Seems your browser doesn't support JavaScript! Websockets rely on JavaScript being enabled. Please enable
+    JavaScript and reload this page!</h2></div>
+<div>
+    <p>
+        <input type="text" placeholder="type and press enter to chat" id="chat" />
+    </p>
+    <div id="console-container">
+        <div id="console"/>
+    </div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/examples/websocket-jms/src/test/config/tomee.xml b/examples/websocket-jms/src/test/config/tomee.xml
new file mode 100644
index 0000000..2078f74
--- /dev/null
+++ b/examples/websocket-jms/src/test/config/tomee.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<tomee>
+    <!-- see http://tomee.apache.org/containers-and-resources.html -->
+
+    <!-- activate next line to be able to deploy applications in apps -->
+    <!-- <Deployments dir="apps" /> -->
+
+    <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
+        # uncomment the config below to connect to an external broker
+        # BrokerXmlConfig  =
+        # ServerUrl = tcp://localhost:61616
+    </Resource>
+
+    <Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
+        ResourceAdapter = MyJmsResourceAdapter
+    </Resource>
+
+    <Container id="MyJmsMdbContainer" ctype="MESSAGE">
+        ResourceAdapter = MyJmsResourceAdapter
+    </Container>
+
+    <Resource id="testTopic" type="javax.jms.Topic"/>
+    <Resource id="messageReceived" type="javax.jms.Topic"/>
+
+</tomee>
\ No newline at end of file
diff --git a/examples/websocket-jms/src/test/resources/arquillian.xml b/examples/websocket-jms/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..60dbed2
--- /dev/null
+++ b/examples/websocket-jms/src/test/resources/arquillian.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+
+    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.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+    <container qualifier="tomee" default="true">
+        <configuration>
+            <property name="httpPort">-1</property>
+            <property name="stopPort">-1</property>
+            <property name="classifier">plus</property>
+            <property name="dir">target/apache-tomee-remote</property>
+            <property name="appWorkingDir">target/arquillian-test-working-dir</property>
+        </configuration>
+    </container>
+</arquillian>
\ No newline at end of file