Skip to content

Commit 5c4804f

Browse files
committed
Document STOMP-related ApplicationContext events
Issue: SPR-11672
1 parent a679f3e commit 5c4804f

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/asciidoc/index.adoc

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37997,7 +37997,7 @@ it acts as a "relay" forwarding messages in both directions.
3799737997

3799837998
[NOTE]
3799937999
====
38000-
Please add a dependency on `org.projectreactor:reactor-tcp` for TCP connection management.
38000+
Please add a dependency on `org.projectreactor:reactor-net` for TCP connection management.
3800138001
====
3800238002

3800338003
Furthermore, application components (e.g. HTTP request handling methods,
@@ -38124,6 +38124,49 @@ for purging inactive destinations.
3812438124

3812538125

3812638126

38127+
[[websocket-stomp-appplication-context-events]]
38128+
==== ApplicationContext Events
38129+
38130+
The STOMP messaging support publishes the `ApplicationContext` events listed below.
38131+
To subscribe to receive one or more of these events a Spring managed component can
38132+
implement Spring's `ApplicationListener` interface. The events are:
38133+
38134+
* `BrokerAvailabilityEvent` -- indicates when the broker becomes available/unavailable.
38135+
While the "simple" broker becomes available immediately on startup and remains so while
38136+
the application is running, the STOMP "broker relay" may lose its connection
38137+
to the full featured broker for example if the broker is restarted. The broker relay
38138+
has reconnect logic and will re-establish the "system" connection to the broker
38139+
when it comes back, hence this event is published whenever the state changes from connected
38140+
to disconnected and vice versa. Components using the `SimpMessagingTemplate` should
38141+
subscribe to this event and avoid sending messages at times when the broker is not
38142+
available. In any case they should be prepared to handle `MessageDeliveryException`
38143+
when sending a message.
38144+
* `SessionConnectEvent` -- published when a new STOMP CONNECT is received
38145+
indicating the start of a new client session. The event contains the message representing the
38146+
connect including the session id, user information (if any), and any custom headers the client
38147+
may have sent. This is useful for tracking client sessions. Components subscribed
38148+
to this event can wrap the contained message using `SimpMessageHeaderAccessor` or
38149+
`StompMessageHeaderAccessor`.
38150+
* `SessionConnectedEvent` -- published shortly after a `SessionConnectEvent` when the
38151+
broker has sent a STOMP CONNECTED frame in response to the CONNECT. At this point the
38152+
STOMP session can be considered fully established.
38153+
* `SessionDisconnectEvent` -- published when a STOMP session ends. The DISCONNECT may
38154+
have been sent from the client or it may also be automatically generated when the
38155+
WebSocket session is closed. In some cases this event may be published more than once
38156+
per session. Components should be idempotent to multiple disconnect events.
38157+
38158+
[NOTE]
38159+
====
38160+
When using a full-featured broker, the STOMP "broker relay" automatically reconnects the
38161+
"system" connection should the broker become temporarily unavailable. Client connections
38162+
however are not automatically reconnected. Assuming heartbeats are enabled, the client
38163+
will typically notice the broker is not responding within 10 seconds. Clients need to
38164+
implement their own reconnect logic.
38165+
====
38166+
38167+
38168+
38169+
3812738170
[[websocket-stomp-configuration-performance]]
3812838171
==== Configuration and Performance
3812938172

0 commit comments

Comments
 (0)