Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Mosca advanced usage

John Kokkinidis edited this page May 8, 2014 · 14 revisions

All the types of brokers we can use:

###Lets set the settings for each one:

  • MongoDB
var pubsubsettings = {
  //using ascoltatore
  type: 'mongo',		
  url: 'mongodb://localhost:27017/mqtt',
  pubsubCollection: 'ascoltatori',
  mongo: {}
};
  • Redis
var pubsubsettings = {
  type: 'redis',
  redis: require('redis'),
  db: 12,
  port: 6379,
  return_buffers: true, // to handle binary payloads
  host: "localhost"
};
  • Mosquitto (! this uses an existing mqtt broker called mosquitto and not mosca as our mqtt server)
var pubsubsettings = {
  type: 'mqtt',
  json: false,
  mqtt: require('mqtt'),
  host: '127.0.0.1',
  port: 1883
};
  • AMQP (RabbitMQ) (! this uses an AQMP server, and not mosca as our mqtt server)
var pubsubsettings = {
  type: 'amqp',
  json: false,
  amqp: require('amqp'),
  exchange: 'ascolatore5672'
};
  • QlobberFSQ (! this uses an AQMP server, and not mosca as our mqtt server) You can use any of the QlobberFSQ constructor options, for example:
var pubsubsettings = {
  type: 'zmq',
  json: false,
  zmq: require("zmq"),
  port: "tcp://127.0.0.1:33333",
  controlPort: "tcp://127.0.0.1:33334",
  delay: 10
};
  • Nothing or just use no settings at all to store everything in memory and not in a pub/sub broker