Polish STOMP documentation

master
Rossen Stoyanchev 11 years ago
parent 77a250ef92
commit 26a9c4bc01
  1. 78
      src/asciidoc/index.adoc

@ -37749,61 +37749,51 @@ sections <<websocket-stomp-handle-broker-relay-configure>> and
[[websocket-stomp-message-flow]] [[websocket-stomp-message-flow]]
==== Flow of Messages ==== Flow of Messages
When a STOMP endpoint is configured, the Spring application becomes the broker to When a STOMP endpoint is configured, the Spring application acts as the STOMP broker
connected clients. It handles incoming messages and broadcasts messages back. to connected clients. It handles incoming messages and sends messages back.
This section provides the big picture of how messages are handled and how This section provides a big picture overview of how messages flow inside the application.
they flow inside the application.
The `spring-messaging` module contains a number of abstractions that originated in the
The `spring-messaging` module contains a number of abstractions for use in https://spring.io/spring-integration[Spring Integration] project and are intended
messaging applications which originated in the for use as building blocks in messaging applications:
https://spring.io/spring-integration[Spring Integration] project and
have been in use for a long time but are now part of the Spring Framework. * {javadoc-baseurl}/org/springframework/messaging/Message.html[Message] --
Listed below are some of the main building blocks:
* {javadoc-baseurl}/org/springframework/messaging/Message.html[Message]
represents a message with headers and a payload. represents a message with headers and a payload.
* {javadoc-baseurl}/org/springframework/messaging/MessageHandler.html[MessageHandler] * {javadoc-baseurl}/org/springframework/messaging/MessageHandler.html[MessageHandler] --
a simple contract components that handle a message. a contract for handling a message.
* {javadoc-baseurl}/org/springframework/messaging/MessageChannel.html[MessageChannel] * {javadoc-baseurl}/org/springframework/messaging/MessageChannel.html[MessageChannel] --
a simple contract for sending a message that enables loose coupling between a contract for sending a message enabling loose coupling between senders and receivers.
senders and receivers. * {javadoc-baseurl}/org/springframework/messaging/SubscribableChannel.html[SubscribableChannel] --
* {javadoc-baseurl}/org/springframework/messaging/SubscribableChannel.html[SubscribableChannel]
extends `MessageChannel` and sends messages to registered `MessageHandler` subscribers. extends `MessageChannel` and sends messages to registered `MessageHandler` subscribers.
* {javadoc-baseurl}/org/springframework/messaging/support/ExecutorSubscribableChannel.html[ExecutorSubscribableChannel] * {javadoc-baseurl}/org/springframework/messaging/support/ExecutorSubscribableChannel.html[ExecutorSubscribableChannel] --
a concrete implementation of `SubscribableChannel` that can deliver messages a concrete implementation of `SubscribableChannel` that can deliver messages
asynchronously using threads from a thread pool. asynchronously through a thread pool.
The above building blocks can be used to construct a message flow.
The provided configuration for STOMP over WebSocket, both Java config and XML namespace, The provided STOMP over WebSocket config, both Java and XML, uses the above to
assemble just such a concrete message flow that consists of the following 3 assemble a concrete message flow including the following 3 channels:
subscribable channels:
* `"clientInboundChannel"` for messages from WebSocket clients; every incoming * `"clientInboundChannel"` -- for messages from WebSocket clients. Every incoming
WebSocket message that is decoded and turned into a Spring Message representing WebSocket message carrying a STOMP frame is sent through this channel.
a STOMP frame is passed through this channel. * `"clientOutboundChannel"` -- for messages to WebSocket clients. Every outgoing
* `"clientOutboundChannel"` for messages to WebSocket clients; every outgoing STOMP message from the broker is sent through this channel before getting sent
Spring Message representing a STOMP frame that is encoded and sent as a to a client's WebSocket session.
WebSocket message is passed through this channel. * `"brokerChannel"` -- for messages to the broker from within the application.
* `"brokerChannel"` for messages to the broker from within the application and Every message sent from the application to the broker passes through this channel.
ultimately intended to reach connected clients; every message that the application
wants to send to clients passes through this channel.
Messages through `"clientInboundChannel"` can flow to annotated Messages on the `"clientInboundChannel"` can flow to annotated
methods for application handling (e.g. a stock trade execution request) or can methods for application handling (e.g. a stock trade execution request) or can
be forwarded to the broker (e.g. client subscribing for stock quotes). be forwarded to the broker (e.g. client subscribing for stock quotes).
The STOMP destination is used for simple prefix-based routing. For example The STOMP destination is used for simple prefix-based routing. For example
the "/app" prefix routes messages annotated methods while the "/topic" or the "/app" prefix could route messages to annotated methods while the "/topic"
"/queue" prefix route messages to the broker. and "/queue" prefixes could route messages to the broker.
When a message-handling annotated method has a return type, its return When a message-handling annotated method has a return type, its return
value is sent as the payload of a Spring Message to the `"brokerChannel"`. value is sent as the payload of a Spring Message to the `"brokerChannel"`.
The broker in turn broadcasts the message to clients. Sending an object as The broker in turn broadcasts the message to clients. Sending a message
the payload of a Message to a specific destination can also easily be done to a destination can also be done from anywhere in the application with
from anywhere in the application with the help of a messaging template. the help of a messaging template. For example a an HTTP POST handling method
For example a an HTTP POST handling method can broadcast a message to can broadcast a message to connected clients or a service component may
connected clients or a service component may periodically broadcast periodically broadcast stock quotes.
stock quotes.
Below is a simple example to illustrate the flow of messages: Below is a simple example to illustrate the flow of messages:
@ -37839,7 +37829,7 @@ Below is a simple example to illustrate the flow of messages:
---- ----
The following explains how messages flow given the above: The following explains the message flow for the above exmaple:
* WebSocket clients connect to the WebSocket endpoint at "/portfolio". * WebSocket clients connect to the WebSocket endpoint at "/portfolio".
* Subscriptions to "/topic/greeting" pass through the "clientInboundChannel" * Subscriptions to "/topic/greeting" pass through the "clientInboundChannel"

Loading…
Cancel
Save