go to  ForumEasy.com   
JavaPro
Home » Archive » Message


[Email To Friend][View in Live Context][prev topic « prev post | next post » next topic]
  Configuration
 
Subject: Configuration
Author: WebSpider
In response to: WebSocket
Posted on: 07/11/2020 12:58:05 AM

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
 
    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic", "/queue");
        config.setApplicationDestinationPrefixes("/channel");
    }
 
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
         registry.addEndpoint("/stomp").withSockJS(); 
    }
}


As the annoation @EnableWebSocketMessageBroker suggests, it will enable MESSAGE handling backed by a broker. Here:
  • ".enableSimpleBroker" -- the simple built-in IN-MEMORY (Simple) message broker (Kafka can be a broker for production);
  • "/topic" -- the destination for subscribers -- a folder holding multiple sub-topics
  • "/channel" -- the destination for publishers -- a folder holding multiple sub-channels
  • "/stomp" -- the STOMP's endpoint for connection (STOMP: Simple Text-Orientated Messaging Protocol)
  • ".withSockJS()" -- with SockJS as fallback if WebSocket is not supported by browser.

     

    > On 07/11/2020 12:57:01 AM WebSpider wrote:

    WebSocket is a protocol to provide bidirectional communication channels over a single TCP connection. It is vital to build the highly interactive real-time web applications like games, chats and bots.


    Dependencies:
  • spring-websocket -- from org.springframework for WebSocket
  • spring-messaging -- from org.springframework for messaging
  • jackson-core -- from com.fasterxml.jackson.core for JSON message
  • jackson-databind -- from com.fasterxml.jackson.core for JSON message




    References:

  •  


     
    Powered by ForumEasy © 2002-2022, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.