Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Use cases

Each page starts from a problem, shows one working solution with mq-bridge, and says where it stops working. Every page has a runnable example in the repository’s examples/ directory that CI executes.

Every page has the same sections: the problem, the solution with a diagram and configuration, a runnable example, failure semantics (restarts, duplicates, deletes, an unavailable sink), when not to use mq-bridge, and a comparison with alternatives.

Keep an index in sync with a database

RAG index sync: Postgres CDC → embeddings → Qdrant. A retrieval-augmented generation (RAG) or semantic-search index drifts from the Postgres rows it was built from. One route reads the table through logical replication, embeds each changed row with an OpenAI-compatible API (a local Ollama in the example) and upserts or deletes the point in Qdrant. Existing rows are copied first. Example: postgres-cdc-to-qdrant.

Search index sync: MongoDB → Meilisearch. Search shows prices and products the database no longer has. One route copies a MongoDB collection and follows its change stream into a Meilisearch index, deletes included; the same input feeds Typesense or Elasticsearch. Example: mongodb-to-meilisearch.

Load a warehouse

Warehouse sync: Postgres CDC → Bloblang → Snowflake. A nightly export leaves the warehouse a day behind and loses every change in between. One route copies a Postgres table and appends each insert, update and delete to a warehouse table, reshaped by a Bloblang mapping and written by a faucet sink, with rejected rows kept in a DLQ. Example: postgres-cdc-to-warehouse.

Add intelligence and context to a stream

LLM triage: classify and route messages. Free-text messages (tickets, emails, reviews) have no field to route by. A model names the category, and a switch routes on the answer, with any answer outside the known categories sent to people. Example: llm-ticket-triage.

Enrich events and add per-key totals. An event needs a database record and what is known about its key so far. A lookup adds the record, an aggregate with a Postgres store adds counts and sums per key that survive restarts and are shared by instances, and outliers go to a review table. Example: order-features.

Reliable messaging in services

Transactional outbox with Postgres and Kafka. A service must update its database and publish an event, and the two writes can diverge. The service writes the event into an outbox table in the same transaction; a route relays it from the WAL to Kafka. Example: transactional-outbox.

Test message handlers without a broker. Tests for Kafka, NATS or RabbitMQ consumers need a running broker or mock the client. The same handler runs against an in-memory endpoint in tests, in Rust and Python. Example: test-without-a-broker.

More recipes

Shorter recipes elsewhere in this book: LLM calls in a pipeline, running aggregates, enrichment and lookups, query a stream in DuckDB, Postgres CDC to a file, cross-process IPC.