ARTEMIS-593 clarify STOMP websocket support
This commit is contained in:
parent
aeafc6a974
commit
146bce08cc
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue