Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 57
WebSockets
WebSockets give you persistent, bidirectional connections — the right tool for chat, live dashboards, notifications.
Course progress0%
Focus
2 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
WebSockets give you persistent, bidirectional connections — the right tool for chat, live dashboards, notifications. Spring's STOMP-over-WebSocket abstraction layers messaging semantics on top.
Informative example
ts
@Configuration @EnableWebSocketMessageBrokerpublic class WsConfig implements WebSocketMessageBrokerConfigurer {public void registerStompEndpoints(StompEndpointRegistry r) {r.addEndpoint("/ws").setAllowedOriginPatterns("*").withSockJS();}public void configureMessageBroker(MessageBrokerRegistry r) {r.enableSimpleBroker("/topic"); // or RabbitMQ for clustersr.setApplicationDestinationPrefixes("/app");}}@Controllerpublic class ChatController {@MessageMapping("/chat") // client sends to /app/chat@SendTo("/topic/messages") // server broadcastspublic ChatMessage send(ChatMessage in) { return in; }}
Ready to mark this lesson complete?Track your journey across the entire course.