mq监听多个队列名
//js //接口获取对讲云信息 ccsGetTalkCloudInfo() function ccsGetTalkCloudInfo() { var token = localStorage.getItem("token") $.ajax({ url: "http://", contentType: "application/json", dataType: "json", beforeSend: function(request) { request.setRequestHeader("token", token); }, type: "get", success: function(m) { console.info("接口获取信息失败!", m) if (m.code == "0000") { if (m.data.length > 0) { for (let i = 0; i < m.data.length; i++) { if (m.data[i].status == "success") { console.info("接口获取信息成功!" + JSON.stringify(m.data[i])) var info = m.data[i]; var ccsRabbitMQ_name = info.name; //用户名 var ccsRabbitMQ_user = info.mquser; //Rabbitmq用户名 var ccsRabbitMQ_pwd = info.mqpwd; //Rabbitmq密码 var ccsRabbitMQ_vhost = info.mqvhost; //Rabbitmqvhost var ccsRabbitMQ_ip = info.mqip; //Rabbitmqip var ccsRabbitMQ_queue = info.mqqueue; //Rabbitmq队列名 init_ccs_webSocket_talkCloud(info.cloudcall_url, ccsRabbitMQ_name, ccsRabbitMQ_user, ccsRabbitMQ_pwd, ccsRabbitMQ_vhost, ccsRabbitMQ_ip, info.token, ccsRabbitMQ_queue); } else { console.info("接口获取信息失败!" + JSON.stringify(m.data[i])) } } } } else { console.info("接口获取信息失败:" + m.msg) } }, }); } function init_ccs_webSocket_talkCloud(cloudcall_url, rabbitMQName, rabbitMQUser, rabbitMQPwd, rabbitMQVHost, rabbitMQIp, rabbitMQToken, rabbitMQQueue) { let url; if (window.location.protocol == "https:") { url = 'wss://' + rabbitMQIp + ':15671/ws'; } if (window.location.protocol == "http:") { url = 'ws://' + rabbitMQIp + ':15674/ws'; } var ws = new WebSocket(url); var allClient = Stomp.over(ws); console.log('对讲 connect success!'); var on_connect = function() { allClient.subscribe('/amq/queue/' + rabbitMQQueue, function(data) { console.log("接收到mq消息: " + data.body); var framecall = JSON.parse(data.body); console.log(framecall) }); }; var on_error = function(e) { console.log("error:" + e); }; allClient.connect(rabbitMQUser, rabbitMQPwd, on_connect, on_error, rabbitMQVHost); allClient.debug = null; }