Messenger.js - dead simple API for multi-server communication in Node.js
github.com
github.com
Discovery and dynamic usage doesn't seem to be covered in many of these projects (cool as they are) which seems to me to be a more challenging and useful extension.
I figure I'll use this space to explain "why" messenger.js even exists.
One reason I wrote messenger.js is because I find it easy to install, work with, and deploy over using RabbitMQ in node. Personally I was using zeromq with node-zeromq.
This means, I need to install zmq, install the node module for it, and anything else that it may need to work properly. In addition I have to do this on dev and production.
On top of that, I also have to write an abstraction over it similar to how the messenger.js listener works right now. To me, there seems to be too many moving parts to the puzzle just to get some simple communication going.
I fell in love with the DNode API at one point, but I have to start my servers first and clients second. It doesn't appear to be a way to capture error events and try to auto-reconnect. There is a ticket for it but it seems neglected. For me, I don't want to worry about that. I want that abstracted away. I also wanted it in TCP, not HTTP.
Of course, the benefit of RabbitMQ is in a separate language, someone probably already wrote the adapter for you to communicate with services of different languages.
I'm not trying to compete with RabbitMQ here though. Just trying to get node.js communication to work in a scalable fashion with a 1 line install that just works.
I'll be keeping an eye on it anyway - you never know when something like that might solve a problem you encounter.
Right now it's as fast as Node.js will allow TCP to be, if that makes any sense.
Benchmarks will come as soon as I get some free time to sit down and do them all. I'll plan to compare with zmq+nodezmq, rabbitmq+nodeamqp, dnode, hook.io. Any others?
TCP just feels cleaner as a protocol for this kind of stuff but I would certainly concede that speed of HTTP isn't as bad as people would make it out to be.
Also, I'm considering adding createFastSpeaker and createFastListener to the API for people like game makers who don't need to guarantee delivery of certain data over UDP.
I certainly need to play with that to find out more. Thanks for the mention!
It feels very websocketish, but with some more infrastructure around it. Would people use this instead of something like socket.io, or are the 2 solving different problems?
Looks pretty cool, either way.
This seems like a simpler API to me.
I'm fairly new to working with Node, so any kind of context for use-cases around some of these libraries is always a help
They all communicate with each other, but in very different ways.
The scraper for example uses fire and forget to send something to the data access layer.
The web app cluster needs to use the request reply model with the data access layer.
The data access layer needs to send pub / sub messages to the stream clusters holding live connections.
I also have a mobile service which does a combination of pub / sub (notify stream servers), req / rep (data access), and fire / forget (analytics).
I needed one library with a 1 line install that handled all of these cases, with the simplest API I could come up with.
On a side note, you can scale what would be single-instance architecture with something like messenger (think an MQtt.js broker).
on other server
messenger.createListener(2222, 2000)
You'll of course have to update your IP Tables.