在客户端使用stomp.js时如何配置stomp协议?

问题描述 投票:0回答:1

下面是我从https://dzone.com/articles/easy-messaging-stomp-over搜索的Web客户端示例代码。

<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个回答
0
投票

基于'ws'的传输连接器适用于希望通过WebSockets通过STOMP连接的客户端。 WebSockets是一种不同的方式,可以将基于TCP的直接套接字传送到基于STOMP的传输连接器,并且需要在其他事物之间进行不同的握手,并且通常在Web浏览器中使用,或者作为初始连接是在防火墙中导航的方式。一个HTTP get。最新的ActiveMQ代理通过基于'ws'的传输连接器端点,通过websockets支持STOMP,MQTT和AMQP。

© www.soinside.com 2019 - 2024. All rights reserved.