Queue System

RouteMQ includes a powerful background task queue system similar to Laravel's queue functionality. This allows you to defer time-consuming tasks (like sending emails, processing data, generating reports) to background workers, keeping your MQTT message handlers fast and responsive.

Overview

The queue system consists of several components:

  • Job: A class that defines a task to be executed in the background

  • Queue Manager: Dispatches jobs to queues

  • Queue Driver: Handles storage and retrieval of jobs (Redis or Database)

  • Queue Worker: Processes jobs from the queue

Architecture

┌─────────────┐
│  Your Code  │
└──────┬──────┘
       │ dispatch(job)

┌─────────────┐
│Queue Manager│
└──────┬──────┘
       │ push

┌─────────────────┐
│  Queue Driver   │
│ (Redis/Database)│
└──────┬──────────┘
       │ pop

┌─────────────┐
│Queue Worker │
│ job.handle()│
└─────────────┘

Quick Start

Key Features

  • Laravel-style API - Familiar syntax for Laravel developers

  • Two Queue Drivers - Redis (fast) or Database (persistent)

  • Automatic Retries - Configurable retry logic with delays

  • Multiple Queues - Organize jobs by priority or type

  • Delayed Jobs - Schedule jobs to run later

  • Failed Job Tracking - Inspect and retry failed jobs

  • Docker Support - Production-ready deployment

  • Graceful Shutdown - Workers handle SIGTERM/SIGINT

Documentation

Example Use Cases

1. Email Notifications

2. Data Processing

3. Scheduled Reports

Next Steps

  1. Configure your queue - Set up Redis or Database

  2. Create your first job - Define a background task

  3. Dispatch jobs - Send jobs from your code

  4. Run workers - Process jobs in background

Last updated