Repository: activemq-artemis Updated Branches: refs/heads/master 5dc5a242b -> 5fa9c0ec8
ARTEMIS-593 clarify STOMP websocket support Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/146bce08 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/146bce08 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/146bce08 Branch: refs/heads/master Commit: 146bce08ccbf713cfbe7aa56632da5d0eafe0c4e Parents: aeafc6a Author: jbertram <[email protected]> Authored: Fri Jun 24 22:05:08 2016 -0500 Committer: jbertram <[email protected]> Committed: Mon Jun 27 14:25:51 2016 -0500 ---------------------------------------------------------------------- .../en/protocols-interoperability.md | 9 ++++---- .../stomp/stomp-websockets/chat/index.html | 6 +++--- .../stomp/stomp-websockets/readme.html | 3 +-- .../jms/example/StompWebSocketExample.java | 22 ++++---------------- 4 files changed, 12 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/146bce08/docs/user-manual/en/protocols-interoperability.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/protocols-interoperability.md b/docs/user-manual/en/protocols-interoperability.md index 65bacef..abfdcf8 100644 --- a/docs/user-manual/en/protocols-interoperability.md +++ b/docs/user-manual/en/protocols-interoperability.md @@ -414,14 +414,13 @@ Apache ActiveMQ Artemis also support Stomp over [Web Sockets](http://dev.w3.org/html5/websockets/). Modern web browser which support Web Sockets can send and receive Stomp messages from Apache ActiveMQ Artemis. -To enable Stomp over Web Sockets, you must configure a `NettyAcceptor` -with a `protocol` parameter set to `stomp_ws`: +Stomp over Web Sockets is supported via the normal Stomp acceptor: - <acceptor name="stomp-ws-acceptor">tcp://localhost:61614?protocols=STOMP_WS</acceptor> + <acceptor name="stomp-ws-acceptor">tcp://localhost:61614?protocols=STOMP</acceptor> With this configuration, Apache ActiveMQ Artemis will accept Stomp connections over Web -Sockets on the port `61614` with the URL path `/stomp`. Web browser can -then connect to `ws://<server>:61614/stomp` using a Web Socket to send +Sockets on the port `61614`. Web browser can +then connect to `ws://<server>:61614` using a Web Socket to send and receive Stomp messages. A companion JavaScript library to ease client-side development is http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/146bce08/examples/protocols/stomp/stomp-websockets/chat/index.html ---------------------------------------------------------------------- diff --git a/examples/protocols/stomp/stomp-websockets/chat/index.html b/examples/protocols/stomp/stomp-websockets/chat/index.html index d92c6e5..5f61e50 100644 --- a/examples/protocols/stomp/stomp-websockets/chat/index.html +++ b/examples/protocols/stomp/stomp-websockets/chat/index.html @@ -37,12 +37,12 @@ under the License. </script> </head> <body> - + <div id='connect'> <form id='connect_form'> <dl> <dt><label for=connect_url>Server URL</label></dt> - <dd><input name=url id='connect_url' value='ws://localhost:61614/stomp'></dd> + <dd><input name=url id='connect_url' value='ws://localhost:61613'></dd> <dt><label for=connect_login>Login</label></dt> <dd><input id='connect_login' placeholder="User Login" value="guest"></dd> <dt><label for=connect_passcode>Password</label></dt> @@ -53,7 +53,7 @@ under the License. <dd><input type=submit id='connect_submit' value="Connect"></dd> </dl> </form> - + <p>Use the form above to connect to the Stomp server and subscribe to the destination.</p> <p>Once connected, you can send messages to the destination with the text field at the bottom of this page</p> </div> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/146bce08/examples/protocols/stomp/stomp-websockets/readme.html ---------------------------------------------------------------------- diff --git a/examples/protocols/stomp/stomp-websockets/readme.html b/examples/protocols/stomp/stomp-websockets/readme.html index 2a3a3e1..98a34ad 100644 --- a/examples/protocols/stomp/stomp-websockets/readme.html +++ b/examples/protocols/stomp/stomp-websockets/readme.html @@ -29,7 +29,6 @@ under the License. <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 from modern web browser using Web Sockets.</p> <p>The example will start a ActiveMQ Artemis server configured with Stomp over Web Sockets and JMS. Web browsers clients and @@ -42,7 +41,7 @@ under the License. <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> <p>To subscribe to the topic from your web browser, open the <a href="chat/index.html">Chat Example</a> or the <a href="aerogear-chat/aerogear-index.html">JBoss AeroGear STOMP notifier Chat Example</a> from another tab. - The chat example is preconfigured to connect to the ActiveMQ Artemis server with the URL <code>ws://localhost:61614/stomp</code> and subscribe to the JMS Topic (through its core address + The chat example is preconfigured to connect to the ActiveMQ Artemis server with the URL <code>ws://localhost:61613</code> and subscribe to the JMS Topic (through its core address <code>jms.topic.chat</code>). </p> <p>You can open as many Web clients as you want and they will all exchange messages through the topic</p> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/146bce08/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java ---------------------------------------------------------------------- diff --git a/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java b/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java index 5ee9187..87af3ab 100644 --- a/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java +++ b/examples/protocols/stomp/stomp-websockets/src/main/java/org/apache/activemq/artemis/jms/example/StompWebSocketExample.java @@ -16,11 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.Date; - import javax.jms.Connection; import javax.jms.ConnectionFactory; -import javax.jms.MessageConsumer; import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TextMessage; @@ -28,8 +25,8 @@ import javax.jms.Topic; import javax.naming.InitialContext; /** - * An example where a client will send a JMS message to a Topic. - * Browser clients connected using Web Sockets will be able to receive the message. + * An example where browser-based clients can send JMS messages to a Topic. + * The clients will be able to exchange messages with each other. */ public class StompWebSocketExample { @@ -44,22 +41,11 @@ public class StompWebSocketExample { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(topic); - MessageConsumer consumer = session.createConsumer(topic); - // use JMS bytes message with UTF-8 String to send a text to Stomp clients - String text = "message sent from a Java application at " + new Date(); - //BytesMessage message = session.createBytesMessage(); - //message.writeBytes(text.getBytes(StandardCharsets.UTF_8)); - TextMessage message = session.createTextMessage(text); - System.out.println("Sent message: " + text); - System.out.println("Open up the chat/index.html file in a browser and press enter"); + System.out.println("Open up the chat/index.html file in a browser...press enter when finished"); System.in.read(); + TextMessage message = session.createTextMessage("Server stopping!"); producer.send(message); - - connection.start(); - - message = (TextMessage) consumer.receive(); - System.out.println("Received message: " + message.getText()); } finally { if (connection != null) {
