PubMQ
PubMQ is a lightweight message queue and pub/sub library that uses a custom protocol implemented as a small layer on top of the UDP protocol. It is idea for real-time communication where asynchronous messages are broadcasted within channels.
Note that PubMQ is connectionless and unreliable (UDP) by design and thus ideal for time critical applications.
Installation
Client:
npm install --save pubmq
Server:
Install PubMQ package globally:
npm install -g pubmq
Install PubMQ server on port 14850
:
pubmq install -p=14850
Create startup script to launch PubMQ on restart: (Checkout PM2 startup script for more info)
pubmq startup <distribution>
Usage
Subscriber
const PubMQClient = Client;let client = ; // Connect to a PubMQ Serverclient; // Output after pub: Hello World
Publisher
const PubMQClient = Client;let client = ; // Connect to a PubMQ Serverclient;
Features & Limitations
Features
- Lightweight code and protocol
- Pub/Sub
- Unsub
- Message Queue
- TTL for Messages
- Direct messaging (upcoming)
Limitations
- Message size is limited to max UDP packet size (about 64kb)
- Messages are only stored in memory (since messages are short lived this shouldn't be an issue)
- Deliveries aren't guaranteed
- No congestion avoidance/control (planned fix)