前提

 安装ActiveMQ和Nodejs

 

测试步骤

1.执行bin\win32\activemq.bat启动MQ服务

2. 打开http://localhost:8161/admin/topics.jsp

用户名和密码都是 admin

3. 下载Stomp

 

npm install stomp-client

4. js的测试代码

 

 

var Stomp = require('stomp-client');
var destination = '/topic/myTopic';
var client = new Stomp('127.0.0.1', 61613, 'user', 'pass');

client.connect(function(sessionId) {
    client.subscribe(destination, function(body, headers) {
      console.log('From MQ:', body);
    });

    client.publish(destination, 'Hello World!');
});

 

 

在NodeJS中执行

 

5. 打开http://localhost:8161/admin/send.jsp?JMSDestination=myTopic&JMSDestinationType=topic

就可以看到从NodeJs发来的消息

 

6.在上述页面的Text Message窗口输入几个字符串,点击Send

在NodeJS窗口就可以看到刚才发送的消息

相关文章:

  • 2022-12-23
  • 2021-05-24
  • 2021-06-14
  • 2021-12-28
  • 2021-04-10
  • 2022-12-23
  • 2022-01-05
  • 2021-07-24
猜你喜欢
  • 2021-12-17
  • 2021-05-25
  • 2022-12-23
  • 2021-06-02
相关资源
相似解决方案