@@ -37749,61 +37749,51 @@ sections <<websocket-stomp-handle-broker-relay-configure>> and
37749
37749
[[websocket-stomp-message-flow]]
37750
37750
==== Flow of Messages
37751
37751
37752
- When a STOMP endpoint is configured, the Spring application becomes the broker to
37753
- connected clients. It handles incoming messages and broadcasts messages back.
37754
- This section provides the big picture of how messages are handled and how
37755
- they flow inside the application.
37756
-
37757
- The `spring-messaging` module contains a number of abstractions for use in
37758
- messaging applications which originated in the
37759
- https://spring.io/spring-integration[Spring Integration] project and
37760
- have been in use for a long time but are now part of the Spring Framework.
37761
- Listed below are some of the main building blocks:
37762
-
37763
- * {javadoc-baseurl}/org/springframework/messaging/Message.html[Message]
37752
+ When a STOMP endpoint is configured, the Spring application acts as the STOMP broker
37753
+ to connected clients. It handles incoming messages and sends messages back.
37754
+ This section provides a big picture overview of how messages flow inside the application.
37755
+
37756
+ The `spring-messaging` module contains a number of abstractions that originated in the
37757
+ https://spring.io/spring-integration[Spring Integration] project and are intended
37758
+ for use as building blocks in messaging applications:
37759
+
37760
+ * {javadoc-baseurl}/org/springframework/messaging/Message.html[Message] --
37764
37761
represents a message with headers and a payload.
37765
- * {javadoc-baseurl}/org/springframework/messaging/MessageHandler.html[MessageHandler]
37766
- a simple contract components that handle a message.
37767
- * {javadoc-baseurl}/org/springframework/messaging/MessageChannel.html[MessageChannel]
37768
- a simple contract for sending a message that enables loose coupling between
37769
- senders and receivers.
37770
- * {javadoc-baseurl}/org/springframework/messaging/SubscribableChannel.html[SubscribableChannel]
37762
+ * {javadoc-baseurl}/org/springframework/messaging/MessageHandler.html[MessageHandler] --
37763
+ a contract for handling a message.
37764
+ * {javadoc-baseurl}/org/springframework/messaging/MessageChannel.html[MessageChannel] --
37765
+ a contract for sending a message enabling loose coupling between senders and receivers.
37766
+ * {javadoc-baseurl}/org/springframework/messaging/SubscribableChannel.html[SubscribableChannel] --
37771
37767
extends `MessageChannel` and sends messages to registered `MessageHandler` subscribers.
37772
- * {javadoc-baseurl}/org/springframework/messaging/support/ExecutorSubscribableChannel.html[ExecutorSubscribableChannel]
37768
+ * {javadoc-baseurl}/org/springframework/messaging/support/ExecutorSubscribableChannel.html[ExecutorSubscribableChannel] --
37773
37769
a concrete implementation of `SubscribableChannel` that can deliver messages
37774
- asynchronously using threads from a thread pool.
37775
-
37776
- The above building blocks can be used to construct a message flow.
37770
+ asynchronously through a thread pool.
37777
37771
37778
- The provided configuration for STOMP over WebSocket, both Java config and XML namespace,
37779
- assemble just such a concrete message flow that consists of the following 3
37780
- subscribable channels:
37772
+ The provided STOMP over WebSocket config, both Java and XML, uses the above to
37773
+ assemble a concrete message flow including the following 3 channels:
37781
37774
37782
- * `"clientInboundChannel"` for messages from WebSocket clients; every incoming
37783
- WebSocket message that is decoded and turned into a Spring Message representing
37784
- a STOMP frame is passed through this channel.
37785
- * `"clientOutboundChannel"` for messages to WebSocket clients; every outgoing
37786
- Spring Message representing a STOMP frame that is encoded and sent as a
37787
- WebSocket message is passed through this channel.
37788
- * `"brokerChannel"` for messages to the broker from within the application and
37789
- ultimately intended to reach connected clients; every message that the application
37790
- wants to send to clients passes through this channel.
37775
+ * `"clientInboundChannel"` -- for messages from WebSocket clients. Every incoming
37776
+ WebSocket message carrying a STOMP frame is sent through this channel.
37777
+ * `"clientOutboundChannel"` -- for messages to WebSocket clients. Every outgoing
37778
+ STOMP message from the broker is sent through this channel before getting sent
37779
+ to a client's WebSocket session.
37780
+ * `"brokerChannel"` -- for messages to the broker from within the application.
37781
+ Every message sent from the application to the broker passes through this channel.
37791
37782
37792
- Messages through `"clientInboundChannel"` can flow to annotated
37783
+ Messages on the `"clientInboundChannel"` can flow to annotated
37793
37784
methods for application handling (e.g. a stock trade execution request) or can
37794
37785
be forwarded to the broker (e.g. client subscribing for stock quotes).
37795
37786
The STOMP destination is used for simple prefix-based routing. For example
37796
- the "/app" prefix routes messages annotated methods while the "/topic" or
37797
- "/queue" prefix route messages to the broker.
37787
+ the "/app" prefix could route messages to annotated methods while the "/topic"
37788
+ and "/queue" prefixes could route messages to the broker.
37798
37789
37799
37790
When a message-handling annotated method has a return type, its return
37800
37791
value is sent as the payload of a Spring Message to the `"brokerChannel"`.
37801
- The broker in turn broadcasts the message to clients. Sending an object as
37802
- the payload of a Message to a specific destination can also easily be done
37803
- from anywhere in the application with the help of a messaging template.
37804
- For example a an HTTP POST handling method can broadcast a message to
37805
- connected clients or a service component may periodically broadcast
37806
- stock quotes.
37792
+ The broker in turn broadcasts the message to clients. Sending a message
37793
+ to a destination can also be done from anywhere in the application with
37794
+ the help of a messaging template. For example a an HTTP POST handling method
37795
+ can broadcast a message to connected clients or a service component may
37796
+ periodically broadcast stock quotes.
37807
37797
37808
37798
Below is a simple example to illustrate the flow of messages:
37809
37799
@@ -37839,7 +37829,7 @@ Below is a simple example to illustrate the flow of messages:
37839
37829
37840
37830
----
37841
37831
37842
- The following explains how messages flow given the above:
37832
+ The following explains the message flow for the above exmaple :
37843
37833
37844
37834
* WebSocket clients connect to the WebSocket endpoint at "/portfolio".
37845
37835
* Subscriptions to "/topic/greeting" pass through the "clientInboundChannel"
0 commit comments