Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

node-stomp

1.0.3 • Public • Published

node-stomp

STOMP Client for Node.js

Build status

const stomp = require('node-stomp');
 
// Set debug to true for more verbose output.
// login and passcode are optional (required by rabbitMQ)
let stomp_args = {
    port: 61613,
    host: 'localhost',
    debug: false,
    login: 'guest',
    passcode: 'guest',
};
 
// 'activemq.prefetchSize' is optional.
// Specified number will 'fetch' that many messages
// and dump it to the client.
let headers = {
    destination: '/queue/test',
    ack: 'client-individual',
    // 'activemq.prefetchSize': '10'
};
 
// Multi-Destinations
{
    destination: [
        '/queue/test_1',
        '/queue/test_2',
    ],
    ack: 'client-individual',
}
 
// Wildcards
{
    destination: '/queue/test.>'
    ack: 'client-individual',
}
 
let messages = 0;
let client = new stomp.Stomp(stomp_args);
 
// start connection with active-mq
client.connect();
 
client.on('connected', function () {
    console.log('[AMQ] Connected');
    client.subscribe(headers);
});
 
client.on('disconnected', function () {
    console.log('[AMQ] Disconnected');
});
 
client.on('message', function (message) {
    messages++;
    console.log("received message : " + message.body[0]);
    client.ack(message.headers['message-id']);
});
 
client.on('error', function (error_frame) {
    console.log('[AMQ] message : ' + error_frame);
    client.disconnect();
});

TODO

  • Support Multi-Destinations
  • Support Wildcards
  • Support Re-Connecting
  • Support Fail-Over
  • Validate
    • headers.ack ['auto','client','client-individual']
    • headers.destination

install

npm i node-stomp

Downloadsweekly downloads

129

version

1.0.3

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability