Benefits
将STOMP用作子协议可以让Spring Framework和Spring Security提供一个更丰富的编程模型,而不是使用原始的WebSocket。同样可以将HTTP与原始TCP进行比较,以及它如何让Spring MVC和其他Web框架提供更丰富的功能。以下是优势列表:
Using STOMP as a sub-protocol lets the Spring Framework and Spring Security provide a richer programming model versus using raw WebSockets. The same point can be made about HTTP versus raw TCP and how it lets Spring MVC and other web frameworks provide rich functionality. The following is a list of benefits:
-
无需发明自定义消息协议和消息格式。
-
No need to invent a custom messaging protocol and message format.
-
STOMP 客户端可用,包括 Spring Framework 中的 Java client。
-
STOMP clients, including a Java client in the Spring Framework, are available.
-
你可以(选择性地)使用消息代理(例如 RabbitMQ、ActiveMQ 等)来管理订阅和广播消息。
-
You can (optionally) use message brokers (such as RabbitMQ, ActiveMQ, and others) to manage subscriptions and broadcast messages.
-
应用程序逻辑可以在任意数量的 `@Controller`实例中组织,消息可以基于 STOMP 目标头路由到它们,而不是使用单个 `WebSocketHandler`处理给定连接的原始 WebSocket 消息。
-
Application logic can be organized in any number of
@Controller
instances and messages can be routed to them based on the STOMP destination header versus handling raw WebSocket messages with a singleWebSocketHandler
for a given connection. -
你可以使用 Spring Security 根据 STOMP 目标和消息类型保护消息。
-
You can use Spring Security to secure messages based on STOMP destinations and message types.