ActiveMQ + NodeJS + Stomp Minimalist Primer

Source: Internet
Author: User
Tags stomp

Prerequisites

Installing ACTIVEMQ and Nodejs


Test Steps

1. Execute Bin\win32\activemq.bat Boot MQ service

2. Open http://localhost:8161/admin/topics.jsp

User name and password are admin

3. Download Stomp

npm install stomp-client
4. JS Test Code

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! ');});


Execute in Nodejs


5. Open Http://localhost:8161/admin/send.jsp?JMSDestination=myTopic&JMSDestinationType=topic

You'll see a message from Nodejs.


6. Enter a few strings in the text message window of the above page, click Send

You can see the message you just sent in the Nodejs window.

ActiveMQ + NodeJS + Stomp Minimalist Primer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.