seneca-mqtt-transport

1.0.2 • Public • Published

seneca-mqtt-transport

NPM

Seneca MQTT transport.

Seneca is a microservices framework and EMQ is an open-source, high-performance, lightweight MQTT cloud messaging system. This library provides a publish-subscribe message distribution model.

Installation

npm install seneca-mqtt-transport

Usage

EMQ server should be running.

// server.js
 
require('seneca')()
  .use('mqtt-transport', {  // Send optional parameters to the library
    mqtt{
      url: 'mqtt://server:port',    //optional. Default mqtt://127.0.0.1:1883
      prefix: 'miservice',          //optional. Default none
      emq: true                     //optional. Support for $queue topic for load balancing. Only EMQ server
    }    
  })
  .add({role: 'foo', cmd: 'bar'}, function(msg, done) { return done(null, msg); })
  .listen({
    type:'mqtt', 
    mqtt: { // You cand send parameters in use method or listen method
      url: 'mqtt://server:port',    //optional. Default mqtt://127.0.0.1:1883
      prefix: 'miservice',          //optional. Default none
      emq: true                     //optional. Support for $queue topic for load balancing. Only EMQ server
    }
  });
// client.js
 
require('seneca')()
  .use('mqtt-transport'{  // Send optional parameters to the library
    mqtt{
      url: 'mqtt://server:port',    //optional. Default mqtt://127.0.0.1:1883
      prefix: 'miservice',          //optional. Default none
      emq: true                     //optional. Support for $queue topic for load balancing. Only EMQ server
    }    
  })
  .client({
    type:'mqtt', 
    mqtt: { // You cand send parameters in use method or listen method
      url: 'mqtt://server:port',    //optional. Default mqtt://127.0.0.1:1883
      prefix: 'miservice',          //optional. Default none
      emq: true                     //optional. Support for $queue topic for load balancing. Only EMQ server
    }
  })
  .act({role: 'foo', cmd: 'bar', arg1: 1, arg2: 2}, console.log);
node server.js
node client.js

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

Package Sidebar

Install

npm i seneca-mqtt-transport

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

13.4 kB

Total Files

11

Last publish

Collaborators

  • sevir