Skip to content

Commit 3526766

Browse files
committed
Fix documentation issue
1 parent 425c311 commit 3526766

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/docs/asciidoc/web/websocket.adoc

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,26 +1292,18 @@ handled under the covers. See <<websocket-stomp-handle-send>>.
12921292
[[websocket-stomp-subscribe-mapping]]
12931293
==== `@SubscribeMapping`
12941294

1295-
The `@SubscribeMapping` annotation is used in combination with `@MessageMapping` in order
1296-
to narrow the mapping to subscription messages. In such scenarios, the `@MessageMapping`
1297-
annotation specifies the destination while `@SubscribeMapping` indicates interest in
1298-
subscription messages only.
1299-
1300-
An `@SubscribeMapping` method is generally no different from any `@MessageMapping`
1301-
method with respect to mapping and input arguments. For example you can combine it with a
1302-
type-level `@MessageMapping` to express a shared destination prefix, and you can use the
1303-
same <<websocket-stomp-message-mapping,method arguments>> as any @MessageMapping` method.
1304-
1305-
The key difference with `@SubscribeMapping` is that the return value of the method is
1306-
serialized as a payload and sent, not to the "brokerChannel" but to the
1307-
"clientOutboundChannel", effectively replying directly to the client rather than
1308-
broadcasting through the broker. This is useful for implementing one-off, request-reply
1309-
message exchanges, and never holding on to the subscription. A common scenario for this
1310-
pattern is application initialization when data must be loaded and presented.
1311-
1312-
A `@SubscribeMapping` method can also be annotated with `@SendTo` in which case the
1313-
return value is sent to the `"brokerChannel"` with the explicitly specified target
1314-
destination.
1295+
`@SubscribeMapping` is similar to `@MessageMapping` but also narrows the mapping to
1296+
subscription messages only. Methods with `@SubscribeMapping` support the same
1297+
<<websocket-stomp-message-mapping,method arguments>> as `@MessageMapping` methods do.
1298+
The main difference is that for the return value, in the absence of `@SendTo` and
1299+
`@SendToUser`, a message is sent directly as a reply to the subscription, via the
1300+
"clientOutboundChannel" channel. Effectively in this case the subscription is used as
1301+
a one-time, request-reply message exchange with the subscription never stored.
1302+
This is useful for loading data on startup and for initializing a front-end UI.
1303+
1304+
If an `@SubscribeMapping` method is annotated with `@SendTo` or `@SendToUser` the return
1305+
value is sent to the `"brokerChannel"` as usual, i.e. sending a message to subscribers
1306+
of the specified destination(s).
13151307

13161308

13171309
[[websocket-stomp-exception-handler]]

0 commit comments

Comments
 (0)