There is no Spring interface named BrokerRegistry. The type you are looking for is MessageBrokerRegistry, the class that Spring passes to configureMessageBroker when you set up STOMP messaging over WebSocket. It decides which destination prefixes the broker handles, whether an in-memory simple broker or an external broker such as RabbitMQ is used, and how application messages reach @MessageMapping methods.
You obtain the registry by implementing WebSocketMessageBrokerConfigurer and enabling broker support with @EnableWebSocketMessageBroker.
registerStompEndpoints defines where clients connect. configureMessageBroker defines how messages flow after the connection. Always list allowed origins explicitly rather than using a wildcard in production.
Two prefix settings decide where a message goes.
| Setting | Example | Where messages are routed |
|---|---|---|
setApplicationDestinationPrefixes | /app | To @MessageMapping methods in your controllers |
enableSimpleBroker | /topic, /queue | To the broker, which forwards them to subscribers |
setUserDestinationPrefix | /user (default) | To one user's sessions, via convertAndSendToUser |
A client sending to /app/chat reaches your controller. The controller's return value or a SimpMessagingTemplate call publishes to /topic/messages, and every client subscribed to that destination receives it.
By convention /topic is for publish and subscribe to many receivers and /queue for point-to-point messages, but the simple broker does not enforce this.
enableSimpleBroker starts an in-memory broker inside your application. It supports a subset of STOMP, keeps subscriptions in memory and does not cluster. That is fine for development and single-instance applications.
For production with several instances, use a broker relay to an external STOMP-capable broker such as RabbitMQ or ActiveMQ.
Port 61613 is the conventional STOMP port of RabbitMQ's STOMP plugin, which must be enabled. Keep credentials in configuration properties or a secret store, not in code. Do not enable the simple broker and the relay for the same prefixes.
The simple broker needs a TaskScheduler if you want server heartbeats.
The values are the server send and receive intervals in milliseconds.
setPreservePublishOrder(true) keeps messages in publish order per session.setCacheLimit(int) bounds the cache of destination lookups.configureBrokerChannel options exist on the channel registrations (configureClientInboundChannel) to tune thread pools.No. The real class is org.springframework.messaging.simp.config.MessageBrokerRegistry.
/app routes to your @MessageMapping methods; /topic is handled by the broker and fans out to subscribers.
No, subscriptions live in one JVM's memory. Use a broker relay for clustered deployments.
Only for browsers or networks without WebSocket support; modern browsers connect with plain WebSocket via addEndpoint("/ws").
Configure STOMP messaging through MessageBrokerRegistry in configureMessageBroker: set the application prefix for controllers, enable the simple broker or a relay to RabbitMQ for broker destinations, and secure the endpoint origins in registerStompEndpoints.