New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of "." as path separator in @MessageMapping methods and in simple broker [SPR-11660] #16283

Closed
spring-issuemaster opened this Issue Apr 4, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Apr 4, 2014

Rossen Stoyanchev opened SPR-11660 and commented

At present STOMP destinations are mapped to @MessageMapping methods with Ant-style patterns. Likewise the simple message broker supports Ant-style patterns style destinations.

This is okay since in STOMP destination are opaque and brokers are free to define the exact semantics. Ant style patterns are an attractive choice for web development due to their similarity to URL paths.

In messaging however "." is more commonly used as a separator and may be a more fitting choice. This ticket is to explore the possibility of using "." instead of "/" as separator. The AntPathMatcher does support using another separator char, so it might even be trivial to switch the style for message mapping purposes.

As for wildcard support it can differ across brokers. A wildcard is commonly used for matching one segment. Recursive matching however varies, e.g. # (hash) in AMQP, ** in Apollo, > in ActiveMQ. It may be relatively easy to make AntPatcher configurable with regards to what it uses for recursive matching. That would make it possible for the simple broker to support all of those and therefore make it easier to switch from the simple broker to a full featured broker.

The configuration could expose this centrally, e.g. default separator, single match and recursive match characters.


Affects: 4.0.3

Sub-tasks:

  • #16623 Improve documentation for using "." vs "/" as separators with STOMP/WebSocket messaging

Referenced from: commits spring-projects/spring-framework-issues@3297657, spring-projects/spring-framework-issues@aeed125

1 votes, 3 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator

spring-issuemaster commented Jul 14, 2014

Rossen Stoyanchev commented

The WebSocket message broker config now allows configuring a PathMatcher, which can be pre-configured to use "." as the path separator. Destination prefixes however are still expected to be slash-separated paths. For example "/topic/price.stock.\*\*" or "/app/price.stock.\*\*. The latter could be mapped to a controller:

@Controller
@MessageMapping("price")
public class PriceController {

    @MessageMapping("stock.**")
    public void handle() {
         // ...
    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment