優點

與使用原始 WebSocket 相比,將 STOMP 作為子協議讓 Spring Framework 和 Spring Security 提供了更豐富的程式設計模型。這與 HTTP 相對於原始 TCP 的情況類似,後者讓 Spring MVC 和其他 Web 框架提供了豐富的功能。以下是其優點列表:

  • 無需發明自定義訊息協議和訊息格式。

  • STOMP 客戶端,包括 Spring Framework 中的 Java 客戶端,都可用。

  • 您可以(可選地)使用訊息代理(如 RabbitMQ、ActiveMQ 等)來管理訂閱和廣播訊息。

  • 應用程式邏輯可以組織在任意數量的 @Controller 例項中,並且可以根據 STOMP 目標頭將訊息路由到它們,而不是為給定連線使用單個 WebSocketHandler 來處理原始 WebSocket 訊息。

  • 您可以使用 Spring Security 根據 STOMP 目標和訊息型別來保護訊息。

© . This site is unofficial and not affiliated with VMware.