MSQE Client Library
High-performance distributed messaging client built for modern Node.js systems.
What is MSQE?
**MSQE (Message Queue Events)** is a distributed messaging and event-streaming platform built entirely with pure Node.js and native Brokers.
It is designed for modern event-driven systems that require lightweight infrastructure, realtime communication, distributed clustering, and simple deployment workflows.
Zero Dependencies
Pure Node.js implementation without requiring Zookeeper or external databases.
Auto-Clustering
Built-in Bully algorithm for automatic leader election and split-brain prevention.
Features
Lightweight Runtime
- Pure Node.js implementation
- Native Broker transport
- Minimal dependencies
- Low memory footprint
- Fast startup time
Realtime Distributed Messaging
- Microservices
- Event-driven systems
- Distributed workers
- Analytics pipelines
- Streaming workloads
Intelligent Failover
- Detects available brokers
- Reconnects during outages
- Automatic failover
- Restores subscriptions
Reliability Features
- Exponential retry backoff
- Offline buffering
- QoS acknowledgements
- Dead letter queue support
Installation
Requirements: Node.js >= 18
# npm npm install msqe-client # yarn yarn add msqe-client # pnpm pnpm add msqe-client
Quick Start
Producer Example
import { Producer } from "msqe-client";
const producer = new Producer({
urls: [
"ws://127.0.0.1:9090",
"ws://127.0.0.1:9091",
"ws://127.0.0.1:9092"
],
autoReconnect: true,
reconnectDelay: 1000
});
producer.on("ready", async () => {
try {
const response = await producer.send(
"user.signup",
{ userId: "user_123", email: "hello@example.com" },
{ qos: 1 }
);
console.log("Published:", response);
} catch (error) {
console.error("Publish failed:", error);
}
});Subscriber Example
import { Subscriber, MessageEnvelope } from "msqe-client";
const subscriber = new Subscriber({
urls: [
"ws://127.0.0.1:9090",
"ws://127.0.0.1:9091",
"ws://127.0.0.1:9092"
],
topics: ["user.signup", "payments.*"],
groupId: "analytics-service",
autoReconnect: true
});
subscriber.run({
eachMessage: async (payload: any, envelope: MessageEnvelope) => {
console.log("Topic:", envelope.topic);
console.log("Payload:", payload);
}
});Architecture
MSQE uses Broker-based broker communication with distributed node coordination, consumer-group balancing, and partition-aware routing.
┌────────────┐ ┌─────────────────┐ ┌────────────┐
│ Producer A │─────▶│ MSQE Broker │◀─────│ Producer B │
└────────────┘ └────────┬────────┘ └────────────┘
│
┌───────────┴───────────┐
┌────────▼────────┐ ┌────────▼────────┐
│ Subscriber A │ │ Subscriber B │
└─────────────────┘ └─────────────────┘Cluster Support
Passing multiple node URLs enables High-Availability mode.
const producer = new Producer({
urls: [
"ws://node-1:9090",
"ws://node-2:9090",
"ws://node-3:9090"
]
});- Multi-node clustering
- Automatic failover
- Distributed partitions
- Consumer balancing
- Replication workflows
- Stateful recovery
API Reference
Producer
new Producer({ url?, urls?, autoReconnect?, reconnectDelay? });
await producer.send(topic, payload, options);
producer.publish(topic, payload);
producer.disconnect();| Method | Description |
|---|---|
| send() | Acknowledged publish |
| publish() | Fire-and-forget publish |
| disconnect() | Graceful shutdown |
Subscriber
new Subscriber({ topics, groupId?, qos?, autoReconnect? });
subscriber.run({ eachMessage: async (payload, envelope) => {} });
subscriber.requestReplay();
subscriber.disconnect();| Method | Description |
|---|---|
| run() | Start consuming messages |
| requestReplay() | Request historical events |
| disconnect() | Graceful shutdown |
Design Philosophy Comparison
| Capability | MSQE | RabbitMQ | Kafka | MQTT |
|---|---|---|---|---|
| Pure Node.js Runtime | ✅ | ❌ | ❌ | ❌ |
| Native Broker Comm. | ✅ | ❌ | ❌ | ⚠️ |
| Lightweight Deployment | ✅ | ⚠️ | ❌ | ✅ |
| Distributed Clustering | ✅ | ✅ | ✅ | ⚠️ |
| Replayable Events | ✅ | ⚠️ | ✅ | ❌ |
| Consumer Groups | ✅ | ✅ | ✅ | ❌ |
Docker & Deployment
docker compose up -d
Supports multi-node orchestration, Docker Swarm, and Kubernetes deployments.
Security
Roadmap
Upcoming features and milestones for MSQE.