architect-stompjs

nodejs architect service that provide messaging based on stompjs.

architect-stompjs

Expose a stompjs client as an architect service. This module provides auto-reconnect functionnality.

npm install --save architect-stompjs
{
  "packagePath": "architect-log4js",
  tcp: {
    host: 'localhost',
    port: 61613
  }
}

Add a tcp object to configure a tcp connection to the stomp server.

  • host : is stomp server hostname, default is localhost
  • port : is stomp server port, default is 61613

Add a ws object to configure a websocket to the stomp server.

  • url : is websocket server url.

Add a headers object to configure connection properties see stompjs connection.

Add a queues object to configure queues alias avaliable in your application.

Boot Architect :

var path = require('path');
var architect = require("architect");
 
var configPath = path.join(__dirname, "config.js");
var config = architect.loadConfig(configPath);
 
architect.createApp(config, function (errapp) {
    if (err) {
        throw err;
    }
    console.log('application started');
});

This module require architect-log4js as logging service.

Configure sptomjs service with config.js :

module.exports = [{
    packagePath: "architect-stompjs"
}{
    packagePath: "architect-log4js"
}, './routes'];

Consume stomp service in your application :

{
  "name": "routes",
  "version": "0.0.1",
  "main": "index.js",
  "private": true,
 
  "plugin": {
    "consumes": ["stomp"]
  }
}

Eventually use the stomp service in your app :

module.exports = function setup(optionsimportsregister) {
    var client = imports.stomp; //get default logger 
    client.send('/queue/myqueue', {}, 'application has started.');
    register();
};

Configure your alias in the architect config.js file :

{
  "packagePath": "architect-log4js",
  tcp: {
    host: 'localhost',
    port: 61613
  },
  queues: {
    'myqueue' : '/queue/my.queue.name.is.super.long'
  }
}

Now you can send and recieve messages with the queue alias :

module.exports = function setup(optionsimportsregister) {
    var client = imports.stomp; //get default logger 
    var myqueue = client.queues.myqueue;
    myqueue.send({}, 'application has started.');
    register();
};