Search code examples
websocketspring-websocket

How to set StompSubProtocolHandler at XML?


My problem is I don't know how i set StompSubProtocolHandler at XML

I try and know normal websocket set

<websocket:handlers allowed-origins="*">
         <websocket:mapping path="/raphaServerHandler.do" handler="raphaServerHandler"/>
   </websocket:handlers>

But I need to know setting StompSubProtocolHandler at XML!


Solution

  • It is done automatically by the:

    <websocket:message-broker application-destination-prefix="/app">
        <websocket:stomp-endpoint path="/foo" />
        <websocket:simple-broker prefix="/topic" />
    </websocket:message-broker>
    

    <xsd:documentation><![CDATA[
    Configures broker-backed messaging over WebSocket using a higher-level messaging sub-protocol.
    Registers a SimpleUrlHandlerMapping and maps paths to registered Controllers.
    
    A StompSubProtocolHandler is registered to handle various versions of the STOMP protocol.
    
    See EnableWebSocketMessageBroker javadoc for information on code-based alternatives to enabling broker-backed messaging.
            ]]></xsd:documentation>
    

    http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-enable