spring-projects / spring-projects/spring-framework

Support for multiple external STOMP message brokers

Open
#22,535 3 comments 0 reactions 1 assignee View on GitHub

@rstoyanchev is already working on this.

Since Mar 13, 2019.

in: web status: feedback-provided type: enhancement
Dominant language
Java
Stars
60.2k
Forks
38.8k
Avg merge
5d 2h
Merged PRs (30d)
27

Description

The problem

<websocket:message-broker> effectively supports only one instance per application, which is a painful limitation in some projects. It would be much better if you could encapsulate different business concerns into separate endpoints with different sets of prefixes and other rules.

I debugged into the issue, trying to find out what could be done and realized that there was not much at the moment.

Specifically, org.springframework.web.socket.config.MessageBrokerBeanDefinitionParser has constants for the names for all beans it is registering, including an instance of SimpMessagingTemplate under the name "brokerMessagingTemplate". This is even mentioned in the official documentation:

The bean name is "brokerMessagingTemplate" if required for qualification with @Qualifier."

This design has its benefits because obviously MessageBrokerBeanDefinitionParser registers quite a couple of beans with some complex wiring. Hiding this complexity is a good thing in general. However, if you look more closely you must admit that this approach totally defeats the idea of IoC because there's nothing you can configure and tweak anymore. Everything is hard-wired, just like direct construction.

I'm sure there would be a better solution.

My current suggestion/vision
  1. <websocket:message-broker> gets an optional argument named something like "broker-messaging-template" by which one can reference any own bean that is an instance of SimpMessagingTemplate to be used for this message broker.
  2. There's another (yet to be implemented) bean definition parser that is able to create these beans, something like <websocket:simp-message-template id="abc">. If no other arguments are given, this creates the default wiring under the name/qualifier "abc". However you should be able to adjust everything (converters, channels, scheduler) if needed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.