ActiveMQ是用于订阅频道,推送消息,监听消息来实现即时通讯
1. 初始化
this.$store.state.user.amq = org.activemq.Amq
this.$store.state.user.amq.init({
uri: '/sjgzxt/amq',
logging: true,
timeout: 2
})
2. 监听消息
var myHandler = {
exception(message) { // 监听异常
console.log('異常')
that.changeWarning()
}
}
this.$store.state.user.amq.addListener('offlineTopic', 'topic://offlineTopic', myHandler.exception)
3. 推送消息
amq.sendMessage("topic://TEST", msg);
4. 结束监听
this.$store.state.user.amq.removeListener('offlineTopic')