@Configuration @EnableWebSocketMessageBroker public class StompConfig extends Object implements org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
| 构造器和说明 |
|---|
StompConfig() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
configureMessageBroker(org.springframework.messaging.simp.config.MessageBrokerRegistry config)
SpringBoot官方说明 Using WebSocket to build an interactive web application:
https://spring.io/guides/gs/messaging-stomp-websocket/
https://www.sitepoint.com/implementing-spring-websocket-server-and-client/
图片说明:
https://docs.spring.io/spring/docs/current/spring-framework-reference/images/message-flow-broker-relay.png
/topic/**: 广播
/queue/**: 点对点
config.enableSimpleBroker("/topic","/queue");
说明:clientLogin/clientPasscode/systemLogin/systemPasscode 必须填写
STOMP messages whose destination header begins with /app are routed to @MessageMapping methods in @Controller classes.
1.
|
void |
configureWebSocketTransport(org.springframework.web.socket.config.annotation.WebSocketTransportRegistration registration)
用于优化 clientOutboundChannel 性能
|
void |
registerStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
setAllowedOrigins 解决跨域问题
/stomp is the HTTP URL for the endpoint to which a WebSocket (or SockJS) client needs to connect for the WebSocket handshake.
|
public void registerStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
registerStompEndpoints 在接口中 org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurerregistry - registrypublic void configureMessageBroker(org.springframework.messaging.simp.config.MessageBrokerRegistry config)
configureMessageBroker 在接口中 org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurerconfig - configpublic void configureWebSocketTransport(org.springframework.web.socket.config.annotation.WebSocketTransportRegistration registration)
configureWebSocketTransport 在接口中 org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurerregistration - registrationCopyright © 2019. All rights reserved.