iamfarhad/laravel-rabbitmq
Production-ready RabbitMQ queue driver for Laravel with native Queue integration. Built on ext-amqp with connection/channel pooling, configurable topology, Horizon hooks, Octane-safe resets, and optional high-performance basic_consume workers plus admin Artisan commands.
sync/database drivers with a high-performance RabbitMQ backend. The package maintains Laravel’s job dispatching API (dispatch(), delay(), onQueue()), ensuring minimal code changes for existing applications.RabbitMQJob) allow access to raw RabbitMQ messages, enabling use cases like non-JSON payloads or custom serialization.QUEUE_CONNECTION=database with QUEUE_CONNECTION=rabbitmq in .env. Existing job classes (App\Jobs\*) require no modifications unless leveraging raw RabbitMQ features..env or config/queue.php, reducing runtime complexity.rabbitmq:queue-declare, rabbitmq:pool-stats), easing operational tasks.ext-amqp (native PHP extension), which may need installation (PECL) and system dependencies (e.g., librabbitmq-dev on Linux). This adds a deployment hurdle but ensures optimal performance.ext-amqp Dependency: Lack of php-amqplib fallback means the package is not portable to environments without ext-amqp. Teams using shared hosting or Docker images without pre-installed extensions may face compatibility issues.consume mode (push-based) requires careful scaling (e.g., one queue per worker process), unlike poll mode (pull-based), which aligns with Laravel’s default worker behavior.RABBITMQ_WORKER=horizon).ext-amqp (PECL, system libraries)?poll (safe, Laravel-compatible) or consume (high-performance, requires tuning) mode?RABBITMQ_OCTANE_RESET_ON_REQUEST=true)?ext-amqp compatibility and modern Laravel features.RABBITMQ_WORKER=horizon).after_commit queue behavior (via RABBITMQ_AFTER_COMMIT=true) may interact with transactional email/job workflows.ext-amqp and system dependencies (e.g., librabbitmq-dev)..env:
QUEUE_CONNECTION=rabbitmq
RABBITMQ_HOST=rabbitmq.example.com
RABBITMQ_USER=laravel
RABBITMQ_PASSWORD=...
test-queue) to validate jobs dispatch and consume correctly.emails, logs) to RabbitMQ.php artisan queue:work with php artisan rabbitmq:consume (or keep using Laravel’s worker with QUEUE_CONNECTION=rabbitmq).--num-processes, --memory, and --timeout based on queue load.dispatch(new Job) or bus()->dispatch() work unchanged.RABBITMQ_WORKER=horizon is set.RABBITMQ_OCTANE_RESET_ON_REQUEST=true if needed.spatie/laravel-queue-scheduler) will work without changes.php artisan vendor:publish --tag=config) and customize config/queue.php.15672) and monitor queue lengths, consumer metrics, and failures.RABBITMQ_MAX_CONNECTIONS, RABBITMQ_MAX_CHANNELS_PER_CONNECTION, and health checks (RABBITMQ_HEALTH_CHECK_INTERVAL) may be needed for stability.rabbitmq:pool-stats, rabbitmq:queue-purge, and rabbitmq:exchange-declare will be necessary for maintenance.ext-amqp and RabbitMQ version compatibility; upgrades may require testing.failed_jobs table is properly configured and monitored.RABBITMQ_MAX_CONNECTIONS) should scale with worker count.consume mode with one queue per worker process; scale by adding more workers (Supervisor/systemd/Kubernetes).consume mode offers higher throughput than poll but requires tuning prefetch counts (RABBITMQ_PREFETCH_COUNT).--memory flag) and timeouts (RABBITMQ_READ_TIMEOUT) to avoid worker crashes.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| RabbitMQ broker down | Jobs stall; workers disconnect. |
How can I help you explore Laravel packages today?