Routing

Learn how to define and organize routes in RouteMQ.

Topics

Quick Overview

Routes in RouteMQ map MQTT topics to handler functions using an expressive syntax:

from core.router import Router
from app.controllers.sensor_controller import SensorController

router = Router()

# Simple route
router.on("sensors/temperature", SensorController.handle_temperature)

# Route with parameters
router.on("devices/{device_id}/status", SensorController.handle_device_status)

# Route with options
router.on("high-volume/{topic}", SensorController.handle_bulk, 
          qos=2, shared=True, worker_count=5)

Route Organization

Router File Structure

Example Router File

Next Steps

Last updated