js接收activeMq消息

参数

var url = "ws://ip:61614";

var userName = "admin";

var pwd = "admin";

引用 stomp.js

//连接

if(window.WebSocket) {
   var destination = "/topic/jcz_board2_yujing"; //topic名称
   client = stomp.client(url);

    // this allows to display debug logs directly on the web page
    client.debug = function(str) {
        console.log(str)
    };
                
    client.connect(userName, pwd, function(frame) {
       client.debug("connected to Stomp");
       client.subscribe(destination, function(message) {
           console.log(message)
       });
  });
}
//断开
mqClient.disconnect(function() {});

猜你喜欢

转载自www.cnblogs.com/lichenx/p/11594506.html