@@ -38168,15 +38168,9 @@ method arguments.
3816838168
3816938169[NOTE]
3817038170====
38171- Although Ant-style, slash-separated, path patterns should feel familiar to web
38172- developers, in message brokers and in messaging it is common to use "." as the
38173- separator, for example in the names of destinations such as topics, queues,
38174- exchanges, etc.
38175- 
38176- Applications can switch to using "." (dot) instead of "/" (slash) as the separator
38177- for destinations mapped to `@MessageMapping` methods simply by configuring an `AntPathMatcher`
38178- with a customized path separator property. This can be done easily through
38179- the provided Java config and XML namespace.
38171+ Applications can switch to using other path separator like "." (dot) instead of
38172+ "/" (slash) as the separator for destinations mapped to `@MessageMapping`.
38173+ For further details, see <<websocket-stomp-destination-separator>>.
3818038174====
3818138175
3818238176The following method arguments are supported for `@MessageMapping` methods:
@@ -38267,15 +38261,9 @@ to Ant-style destination patterns.
3826738261
3826838262[NOTE]
3826938263====
38270- Although Ant-style, slash-separated, path patterns should feel familiar to web
38271- developers, in message brokers and in messaging it is common to use "." as the
38272- separator, for example in the names of destinations such as topics, queues,
38273- exchanges, etc.
38274- 
38275- Applications can switch to using "." (dot) instead of "/" (slash) as the separator
38276- for destinations handled by the broker simply by configuring an `AntPathMatcher`
38277- with a customized path separator property. This can be done easily through
38278- the provided Java config and XML namespace.
38264+ Applications can switch to using other path separator like "." (dot) instead of
38265+ "/" (slash) as the separator for destinations mapped to `@MessageMapping`.
38266+ For further details, see <<websocket-stomp-destination-separator>>.
3827938267====
3828038268
3828138269
@@ -38407,6 +38395,107 @@ and may be useful for example in a cloud environment where the actual host to wh
3840738395the TCP connection is established is different from the host providing the
3840838396cloud-based STOMP service.
3840938397
38398+ [[websocket-stomp-destination-separator]]
38399+ ==== Destination separator
38400+ 
38401+ Although Ant-style, slash-separated, path patterns should feel familiar to web developers,
38402+ in message brokers and in messaging it is common to use "." as the separator, for example
38403+ in the names of destinations such as topics, queues, exchanges, etc.
38404+ 
38405+ Applications can switch to using "." (dot) instead of "/" (slash) as the separator for
38406+ destinations handled by the broker simply by configuring an AntPathMatcher with a customized
38407+ path separator property. This can be done easily through the provided Java config and XML
38408+ namespace.
38409+ 
38410+ Below is example configuration that enables using "." separator:
38411+ 
38412+ [source,java,indent=0]
38413+ [subs="verbatim,quotes"]
38414+ ----
38415+   @Configuration
38416+   @EnableWebSocketMessageBroker
38417+   public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
38418+ 
38419+     @Override
38420+     public void registerStompEndpoints(StompEndpointRegistry registry) {
38421+       registry.addEndpoint("/stomp");
38422+     }
38423+ 
38424+     @Override
38425+     public void configureMessageBroker(MessageBrokerRegistry registry) {
38426+       registry.enableStompBrokerRelay("/queue/", "/topic/");
38427+       registry.setApplicationDestinationPrefixes("/app");
38428+       registry.setPathMatcher(new AntPathMatcher("."));
38429+     }
38430+ 
38431+   }
38432+ ----
38433+ 
38434+ XML configuration equivalent:
38435+ 
38436+ [source,xml,indent=0]
38437+ [subs="verbatim,quotes,attributes"]
38438+ ----
38439+   <beans xmlns="http://www.springframework.org/schema/beans"
38440+     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
38441+     xmlns:websocket="http://www.springframework.org/schema/websocket"
38442+     xsi:schemaLocation="
38443+       http://www.springframework.org/schema/beans
38444+       http://www.springframework.org/schema/beans/spring-beans.xsd
38445+       http://www.springframework.org/schema/websocket
38446+       http://www.springframework.org/schema/websocket/spring-websocket-4.1.xsd">
38447+ 
38448+     <bean id="pathMatcher" class="org.springframework.util.AntPathMatcher">
38449+       <constructor-arg index="0" value="." />
38450+     </bean>
38451+ 
38452+     <websocket:message-broker application-destination-prefix="/app" path-matcher="pathMatcher">
38453+       <websocket:stomp-endpoint path="/stomp" />
38454+       <websocket:simple-broker prefix="/topic, /queue"/>
38455+     </websocket:message-broker>
38456+ 
38457+   </beans>
38458+ ----
38459+ 
38460+ And below is a simple example to illustrate a controller with "." separator:
38461+ 
38462+ [source,java,indent=0]
38463+ [subs="verbatim,quotes"]
38464+ ----
38465+   @Controller
38466+   public class FooController {
38467+     
38468+     @MessageMapping("foo.{bar}")
38469+     public String foo(@DestinationVariable String bar) {
38470+       return bar;
38471+     }
38472+   }
38473+ ----
38474+ 
38475+ If the application prefix configured is "/app", the foo method will be mapped
38476+ to the "/app/foo.{bar}" destination. If bar="value", "value" will be sent to
38477+ the "/topic/foo.value" destination.
38478+ 
38479+ You can also use type + method level `@MessageMapping` annotations:
38480+ 
38481+ [source,java,indent=0]
38482+ [subs="verbatim,quotes"]
38483+ ----
38484+   @Controller
38485+   @MessageMapping("foo")
38486+   public class FooController {
38487+ 
38488+     @MessageMapping("{bar}")
38489+     public String foo(@DestinationVariable String bar) {
38490+       return bar;
38491+     }
38492+   }
38493+ ----
38494+ 
38495+ In this example, the "." separator will be automatically added when combining "foo"
38496+ and "{bar}", so the foo method will be mapped to the "/app/foo.{bar}" destination,
38497+ like in the previous example.
38498+ 
3841038499[[websocket-stomp-authentication]]
3841138500==== Authentication
3841238501
0 commit comments