Polish
This commit is contained in:
@@ -38168,9 +38168,8 @@ method arguments.
|
|||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
Applications can switch to using other path separator like "." (dot) instead of
|
Applications can also use dot-separated destinations (vs slash).
|
||||||
"/" (slash) as the separator for destinations mapped to `@MessageMapping`.
|
See <<websocket-stomp-destination-separator>>.
|
||||||
For further details, see <<websocket-stomp-destination-separator>>.
|
|
||||||
====
|
====
|
||||||
|
|
||||||
The following method arguments are supported for `@MessageMapping` methods:
|
The following method arguments are supported for `@MessageMapping` methods:
|
||||||
@@ -38261,9 +38260,8 @@ to Ant-style destination patterns.
|
|||||||
|
|
||||||
[NOTE]
|
[NOTE]
|
||||||
====
|
====
|
||||||
Applications can switch to using other path separator like "." (dot) instead of
|
Applications can also use dot-separated destinations (vs slash).
|
||||||
"/" (slash) as the separator for destinations mapped to `@MessageMapping`.
|
See <<websocket-stomp-destination-separator>>.
|
||||||
For further details, see <<websocket-stomp-destination-separator>>.
|
|
||||||
====
|
====
|
||||||
|
|
||||||
|
|
||||||
@@ -38396,18 +38394,14 @@ the TCP connection is established is different from the host providing the
|
|||||||
cloud-based STOMP service.
|
cloud-based STOMP service.
|
||||||
|
|
||||||
[[websocket-stomp-destination-separator]]
|
[[websocket-stomp-destination-separator]]
|
||||||
==== Destination separator
|
==== Using Dot as Separator in `@MessageMapping` Destinations
|
||||||
|
|
||||||
Although Ant-style, slash-separated, path patterns should feel familiar to web developers,
|
Although slash-separated path patterns are familiar to web developers, in messaging
|
||||||
in message brokers and in messaging it is common to use "." as the separator, for example
|
it is common to use "." as separator for example in the names of topics, queues,
|
||||||
in the names of destinations such as topics, queues, exchanges, etc.
|
exchanges, etc. Applications can also switch to using "." (dot) instead of "/" (slash)
|
||||||
|
as the separator in `@MessageMapping` mappings by configuring a custom `AntPathMatcher`.
|
||||||
|
|
||||||
Applications can switch to using "." (dot) instead of "/" (slash) as the separator for
|
In Java config:
|
||||||
destinations handled by the broker simply by configuring an AntPathMatcher with a customized
|
|
||||||
path separator property. This can be done easily through the provided Java config and XML
|
|
||||||
namespace.
|
|
||||||
|
|
||||||
Below is example configuration that enables using "." separator:
|
|
||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
@@ -38416,10 +38410,7 @@ Below is example configuration that enables using "." separator:
|
|||||||
@EnableWebSocketMessageBroker
|
@EnableWebSocketMessageBroker
|
||||||
public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
public class WebsocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
||||||
|
|
||||||
@Override
|
// ...
|
||||||
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
|
||||||
registry.addEndpoint("/stomp");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||||
@@ -38431,7 +38422,7 @@ Below is example configuration that enables using "." separator:
|
|||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
XML configuration equivalent:
|
In XML config:
|
||||||
|
|
||||||
[source,xml,indent=0]
|
[source,xml,indent=0]
|
||||||
[subs="verbatim,quotes,attributes"]
|
[subs="verbatim,quotes,attributes"]
|
||||||
@@ -38443,41 +38434,22 @@ XML configuration equivalent:
|
|||||||
http://www.springframework.org/schema/beans
|
http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/websocket
|
http://www.springframework.org/schema/websocket
|
||||||
http://www.springframework.org/schema/websocket/spring-websocket-4.1.xsd">
|
http://www.springframework.org/schema/websocket/spring-websocket.xsd">
|
||||||
|
|
||||||
<bean id="pathMatcher" class="org.springframework.util.AntPathMatcher">
|
|
||||||
<constructor-arg index="0" value="." />
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<websocket:message-broker application-destination-prefix="/app" path-matcher="pathMatcher">
|
<websocket:message-broker application-destination-prefix="/app" path-matcher="pathMatcher">
|
||||||
<websocket:stomp-endpoint path="/stomp" />
|
<websocket:stomp-endpoint path="/stomp" />
|
||||||
<websocket:simple-broker prefix="/topic, /queue"/>
|
<websocket:simple-broker prefix="/topic, /queue"/>
|
||||||
</websocket:message-broker>
|
</websocket:message-broker>
|
||||||
|
|
||||||
|
<bean id="pathMatcher" class="org.springframework.util.AntPathMatcher">
|
||||||
|
<constructor-arg index="0" value="." />
|
||||||
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
----
|
----
|
||||||
|
|
||||||
And below is a simple example to illustrate a controller with "." separator:
|
And below is a simple example to illustrate a controller with "." separator:
|
||||||
|
|
||||||
[source,java,indent=0]
|
|
||||||
[subs="verbatim,quotes"]
|
|
||||||
----
|
|
||||||
@Controller
|
|
||||||
public class FooController {
|
|
||||||
|
|
||||||
@MessageMapping("foo.{bar}")
|
|
||||||
public String foo(@DestinationVariable String bar) {
|
|
||||||
return bar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
----
|
|
||||||
|
|
||||||
If the application prefix configured is "/app", the foo method will be mapped
|
|
||||||
to the "/app/foo.{bar}" destination. If bar="value", "value" will be sent to
|
|
||||||
the "/topic/foo.value" destination.
|
|
||||||
|
|
||||||
You can also use type + method level `@MessageMapping` annotations:
|
|
||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
[subs="verbatim,quotes"]
|
[subs="verbatim,quotes"]
|
||||||
----
|
----
|
||||||
@@ -38485,16 +38457,17 @@ You can also use type + method level `@MessageMapping` annotations:
|
|||||||
@MessageMapping("foo")
|
@MessageMapping("foo")
|
||||||
public class FooController {
|
public class FooController {
|
||||||
|
|
||||||
@MessageMapping("{bar}")
|
@MessageMapping("bar.{baz}")
|
||||||
public String foo(@DestinationVariable String bar) {
|
public void handleBaz(@DestinationVariable String baz) {
|
||||||
return bar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
In this example, the "." separator will be automatically added when combining "foo"
|
If the application prefix is set to "/app" then the foo method is effectively mapped to "/app/foo.bar.{baz}".
|
||||||
and "{bar}", so the foo method will be mapped to the "/app/foo.{bar}" destination,
|
|
||||||
like in the previous example.
|
|
||||||
|
|
||||||
|
|
||||||
[[websocket-stomp-authentication]]
|
[[websocket-stomp-authentication]]
|
||||||
==== Authentication
|
==== Authentication
|
||||||
|
|||||||
Reference in New Issue
Block a user