【发布时间】:2018-10-11 11:27:42
【问题描述】:
我在节点 js 中使用 stompit 模块连接 activeMQ。
我的问题:stompit.ConnectFailover 中无法识别代理是否已连接
这是我的代码:
var stompit = require('stompit')
var connectionManager = new stompit.ConnectFailover();
connectionManager.addServer({
'host': 'localhost',
'port': 61623,
'connectHeaders':{
...
}
});
var channel = new stompit.Channel(connectionManager);
var subscribeHeaders = {
'destination': '/queue/test',
'ack': 'client'
};
channel.subscribe(subscribeHeaders, function(error, message){
if (error) {
console.log(error);
return;
}
});
//send . But not throw error , even broker is not started
//always trying to reconnect
sendDlQ(subscribeHeaders, 'Hello');
function sendDlQ(header, body){
channel.send(header, body);
}
无论何时调用 send 方法,总是成功。 连broker都没有启动。
发送前如何判断broker是否连接?
【问题讨论】: