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

 

posted @ 2019-11-22 11:26  scd  阅读(2178)  评论(0编辑  收藏  举报