The simple broker stores subscriptions in one application process; a shared broker relay changes routing and failure ownership.
Spring STOMP simple broker versus relay: the multi-instance boundary
A local subscription has a location
With the simple broker, instance A knows its own connected subscribers. If an HTTP request lands on instance B and B broadcasts an event, B cannot assume A's clients receive it. Sticky routing may hide this in a test but fails when a connection moves or an instance dies. A broker relay forwards messages to an external STOMP broker, giving multiple application instances a shared route; it also creates a broker dependency that needs health and reconnect policies.
Separate live delivery from durable history
Neither a WebSocket connection nor a broker relay means an offline browser will later receive missed stock events. Keep durable events or current state in a store and send a snapshot after reconnect. Shared HTTP session state does not share the simple broker's subscription table. Slow-client limits still apply at the WebSocket edge even when the broker is external.
Prove cross-node delivery
Attach a subscriber to instance A, publish through instance B, then restart A and reconnect the browser. Assert an authorized subscriber receives the live event and a snapshot restores missed state. Add a broker outage case. The relay snippet is only the application-side configuration; broker credentials, destinations and capacity require a deployment test.
Implementation sketch
registry.enableStompBrokerRelay("/topic", "/queue")
.setRelayHost("broker.internal")
.setRelayPort(61613);
registry.setApplicationDestinationPrefixes("/app");Cost and verification
A relay adds network hops and broker operations but lets separate app instances route to the same subscription space. Durability requires a distinct persistence design.
Common Mistakes
- Do not assume the simple broker shares subscriptions between replicas.
- Do not call a live STOMP frame a durable notification.
- Do not skip a broker-outage and reconnect test when moving to a relay.
Read next
Spring WebSocket and STOMP: authenticate the handshake, authorize messages, Spring WebSocket STOMP identity: authenticate the handshake, authorize destinations, Spring STOMP slow clients: send buffer and message-size limits, Spring Session Redis across replicas: shared login state has a Redis failure boundary.
Related boundary
Spring STOMP broker relay: credentials and broker availability are separate from user identity
