Skip to main content

Five-minute quickstart

This example sends one message per second and receives it on a topic. Python and C++ use a direct ZeroMQ connection; TypeScript uses MQTT because browsers and Node.js do not expose a ZeroMQ transport.

Install the core package:

pip install luxai-magpie

Create writer.py:

import time
from luxai.magpie.transport import ZmqStreamWriter

writer = ZmqStreamWriter("tcp://*:5555")

try:
count = 0
while True:
writer.write({"count": count, "message": "hello"}, topic="demo/hello")
count += 1
time.sleep(1)
finally:
writer.close()

Create reader.py:

from luxai.magpie.transport import ZmqStreamReader

reader = ZmqStreamReader("tcp://127.0.0.1:5555", topic=["demo/hello"], bind=False)

try:
while True:
data, topic = reader.read()
print(topic, data)
finally:
reader.close()

Run python writer.py, then python reader.py in another terminal.

What just happened?​

The writer knew only an endpoint and a topic. The reader subscribed independently, and MAGPIE handled serialization, transport I/O, queues, and shutdown behavior. Changing transport should change construction and connection setup—not the application’s message-handling logic.

Next, learn the four core APIs, add request/response RPC, or compare transport choices.