The routing system is the heart of RouteMQ, providing Laravel-style route definitions with parameter extraction:
Router: Main routing class that manages route definitions
Route: Individual route definitions with topic patterns, handlers, and configuration
RouterGroup: Groups routes with shared prefixes and middleware
# Example route definitionrouter.on("sensors/{device_id}/data", DeviceController.handle_data,qos=1)# Route groups with shared configurationwith router.group(prefix="sensors",middleware=[AuthMiddleware()])as devices: devices.on("message/{device_id}", DeviceController.handle_message)
2. Router Registry
Automatically discovers and loads route files from the application:
Dynamic Discovery: Scans the app/routers directory for route definitions
Module Loading: Imports and merges routes from multiple files
Hot Reloading: Can reload routes during development
3. Middleware Pipeline
Processes messages before they reach route handlers:
Chain Processing: Middleware executes in order with next() pattern
Context Passing: Shared context dictionary passes through the chain
Early Termination: Middleware can stop processing by not calling next()
4. Controller Architecture
Handles business logic with clean separation of concerns:
Async Support: Built for non-blocking operations
Dependency Injection: Access to Redis, database, and MQTT client