当前位置:首页 > Web开发 > 正文

js接收activeMq消息

2024-03-31 Web开发

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() {});

js接收activeMq消息

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/43033.html