
Getting Started with TYO MQ
TYO MQ's design goal is that the first five minutes are trivial and nothing you learn in them is thrown away later — the API you start with is the API that runs on a Redis-backed cluster. Here's the whole journey.
1. Install
npm install tyo-mq
That's the server, the Node.js client, and the browser client bundle in one package, Apache-2.0 licensed.
2. Start a server
const { Server } = require('tyo-mq');
const server = new Server();
server.start(); // listens on 17352 by default
3. Produce and subscribe
const { Factory } = require('tyo-mq');
const factory = new Factory();
// a producer announces events
const producer = await factory.createProducer('order-service');
producer.produce('order-placed', { orderId: 1001, total: 129.0 });
// a consumer reacts to them
const consumer = await factory.createConsumer('email-service');
consumer.subscribe('order-service', 'order-placed', (order) => {
console.log('sending confirmation for order', order.orderId);
});
Events flow in real time to every subscriber. That's the whole core model — everything else is options on these calls.
4. Turn on the production features as you need them
Guaranteed delivery — mark the subscription durable and acknowledged; the server queues while the consumer is offline, replays on reconnect, retries on your schedule, and dead-letters what keeps failing:
consumer.subscribe('order-service', 'order-placed', handler, {
durable: true,
ack: true,
retry: { max_attempts: 3, delay: '5s', backoff: 'exponential' }
});
Topic wildcards and worker pools — MQTT-style patterns and consumer groups compose with everything above:
monitor.subscribe('orders/#', handler, { mode: 'topic' });
worker.subscribe('dispatcher', 'jobs', handler, { group: 'workers' });
Authentication and realms — tokens scope every client to an isolated realm; JWTs, pre-shared keys, and an approval workflow for onboarding new integrations are all built in:
const server = new Server({
auth: {
enabled: true,
tokens: [{ token: 'acme-secret', realm: 'acme', role: 'both' }]
}
});
const client = new Factory({ auth: { token: 'acme-secret' } });
Observability — one option serves /health, Prometheus metrics,
per-realm stats, and dead-letter queue contents on the same port:
const server = new Server({ http_api: { enabled: true } });
Persistence and clustering — queues survive restarts with one line
({ storage: 'sqlite' }), and Redis unlocks both shared storage and a
multi-node cluster:
{
"storage": "redis",
"storage_options": { "url": "redis://10.0.0.5:6379/0" },
"cluster": { "enabled": true }
}
Docker — the repository ships a Dockerfile and docker-compose.yaml,
including a managed admin token and a persistent settings volume.
5. Bring the rest of your stack
The examples above are Node.js, but the backbone isn't tied to it: official clients exist for seven more languages, all speaking the same wire protocol with the same durable/ACK/topic/group options.
| Language | Repository | Install |
|----------|------------|---------|
| Python | tyo-mq-client-python | pip install tyo-mq-client |
| Go | tyo-mq-client-go | go get github.com/tyolab/tyo-mq-client-go |
| Rust | tyo-mq-client-rust | git dependency (crates.io soon) |
| C/C++ | tyo-mq-client-cpp | CMake FetchContent |
| Java | tyo-mq-client-java | Maven au.com.tyo:tyo-mq-client |
| C# / .NET | tyo-mq-client-csharp | dotnet add package TYO_MQ_CLIENT |
| Ruby | tyo-mq-client-ruby | gem install tyo-mq-client |
Ten lines of Python looks just like ten lines of Node:
from tyo_mq_client import MessageQueue
mq = MessageQueue(host='localhost')
consumer = mq.createConsumer('email-service')
consumer.subscribe('order-service', 'order-placed', handle_order,
options={'durable': True, 'ack': True})
consumer.connect()
6. Learn from running code
The fastest path from here isn't documentation — it's the tyo-mq-samples repository:
- a seven-recipe cookbook, one self-contained script per feature — each starts its own server, demonstrates one idea, and exits;
- eight mini-apps — webhook delivery with retries and DLQ, a background job queue, a live browser dashboard, an IoT fleet, event-driven microservices, a multi-tenant hub with live approval, a crash-surviving audit trail, and a chat room.
git clone https://github.com/tyolab/tyo-mq-samples.git
cd tyo-mq-samples && npm install
npm run job-queue # the 60-second tour
Full documentation — authentication flows, persistence, clustering, the manager UI — lives in the main repository: github.com/tyolab/tyo-mq.
Node.js 18 or newer (22+ for the built-in SQLite backend). The server runs anywhere Node runs — Linux, macOS, Windows, containers, or a $5 VPS.
Stuck, scaling, or planning something ambitious? TYO MQ is a core TYO Lab product and our development team works with it daily — get in touch for integration help, custom features, or production support.
