Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including stompjs-nodejs with all npm packages installed. Try it out:

var stompjsNodejs = require("stompjs-nodejs")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

stompjs-nodejs v0.0.3

A nodejs wrapper for stompjs

stompjs-nodejs

Wrapper for stompjs works with nodejs and with typings

Usage

npm i stompjs-nodejs --save

example with active MQ.

import { StompClient } from 'stompjs-nodejs';

const client = new StompClient({
    brokerUrl: 'ws://localhost:61614/ws',
    user: 'user',
    password: 'password',
});

client.subsribe('/topic/name', (msg) => {
    console.log('received', msg);
});

client.publish('/topic/name', 'a message to pub');

subsribe and publish will auto connect at first call (lazy init)

but if you want to connect in advance, can do

await client.connect()

Notes

Currently it only tested to work with active MQ, I did not test on other MQ lib.

Currently this wrapper only works for pub/sub mode, doesn't work for queue yet.

contributions are welcome.

Special thanks to original authors of stompjs https://github.com/stomp-js/stompjs

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free