【问题标题】:How to configure stomp protocal when using stomp.js in client?在客户端使用 stompjs 时如何配置 stomp 协议?
【发布时间】:2018-06-03 22:28:55
【问题描述】:

以下是我从https://dzone.com/articles/easy-messaging-stomp-over google 搜索到的网络客户端示例代码。

<script type="text/javascript">   
 var client = Stomp.client( "ws://localhost:61614/stomp", "v11.stomp" );    
 client.connect( "", "",    
  function() {
      client.subscribe("jms.topic.test",    
       function( message ) {                   
           alert( message );    
        }, { priority: 9 }     
      );
   client.send("jms.topic.test", { priority: 9 }, "Pub/Sub over STOMP!");
  }    
 );

</script>

我的问题是为什么将 activemq 连接到 'ws://localhost:61614/stomp' 而不是 'stomp://localhost:61614/stomp'? activemq.xml中的以下协议有什么区别?

<transportConnectors>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61613"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61614"/>
</transportConnectors>

【问题讨论】:

    标签: websocket activemq stomp


    【解决方案1】:

    基于“ws”的传输连接器适用于希望通过 WebSockets 通过 STOMP 进行连接的客户端。 WebSockets 是一种将直接基于 TCP 的套接字与基于 STOMP 的传输连接器进行通信的不同方式,并且需要不同的握手,并且通常在 Web 浏览器中使用,或者作为通过防火墙导航的方式,因为初始连接是HTTP 获取。最新的 ActiveMQ 代理通过基于 'ws' 的传输连接器端点支持 STOMP、MQTT 和 AMQP over websockets。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-01
      • 2016-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多