waterfront

a small but mighty message broker

waterfront

A message broker system built on ZeroMQ with discovery patterns for push/pull, req/rep, pub/sub.

Messaging libraries provide low level building blocks for designing messaging patterns. Although fairly easy to build, all the ports to bind and connect to can be difficult to keep track of when managing intermediaries in prodiction. Waterfront provides a simple robust messaging broker/client to make it easier to build distributed systems.

This method is for standing up a woterfront message broker. It is the centralized component.

var waterfront = require('waterfront').listen()
var waterfront = require('waterfront').connect()

socket returns an axon socket based on the type that is passed in. possible values for type are: push, pull, req, rep, pub, sub.

var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("push")
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('push')

setInterval(function(){
  sock.send({ "date" : (+new Date) })
}, 200)
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('pull')

sock.on('message', function(data){
  console.log(data)
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('req')

sock.send({ req: +new Date }, function(rep){
  console.log(rep)
  process.exit()
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('rep')

sock.on('message', function(data, callback){
  data.rep = +new Date
  callback(data)
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("pub")

setInterval(function(){
  sock.send('message', { pub: +new Date })
}, 200)
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("sub")

sock.on('message', function(msg){
  console.log(msg)
})