SpringBootWebSocket生产准备好了吗?

hgqdbh6s  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(223)

我正在用spring boot在java中实现一个stomp端点,下面是我的依赖项和代码:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.4.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
...
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
</dependency>

java配置:

@Configuration
@EnableWebSocketMessageBroker
public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {

    @Value("${wschannel.name}")
    private String wsChannel;

    @Value("${topic.prefix}")
    private String topic;

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
         registry.addEndpoint("/"+wsChannel).setAllowedOrigins("*");
         registry.addEndpoint("/"+wsChannel).setAllowedOrigins("*").withSockJS();
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker(topic+"/");
    }
}

它起作用了,但我不能理解以下内容:
spring boot提供了什么样的websocket服务器?
生产准备好了吗?
我还可以访问redis集群:我可以将其用作websocket代理吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题