zoukankan      html  css  js  c++  java
  • ActiveMQ + NodeJS + Stomp 极简入门

    前提

     安装ActiveMQ和Nodejs

    测试步骤

    1.执行binwin32activemq.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窗口就可以看到刚才发送的消息

  • 相关阅读:
    Nexus3.0私服搭建
    JavaScript
    Spring基础
    Hibernate注解
    HTML5
    Apache Tomcat
    Java安装(Ubuntu)
    C++ 日期 & 时间
    C++ 引用
    C++ 指针
  • 原文地址:https://www.cnblogs.com/c-x-a/p/5458439.html
Copyright © 2011-2022 走看看