- How do I switch from Laravel’s default database queue to RabbitMQ using this package?
- Simply update your `.env` file to set `QUEUE_CONNECTION=rabbitmq`. No changes are needed to your existing job classes unless you’re using raw RabbitMQ features. The package maintains full Laravel queue API compatibility, so `dispatch()`, `delay()`, and `onQueue()` will work as before.
- Does this package support Laravel Horizon for monitoring?
- Yes, it integrates with Horizon out of the box. Set `RABBITMQ_WORKER=horizon` in your `.env` and configure Horizon as usual. The package includes Horizon hooks for seamless monitoring of RabbitMQ jobs, including queue metrics and failed job tracking.
- What are the system requirements for ext-amqp and RabbitMQ?
- You’ll need PHP 8.2+, the `ext-amqp` extension (installed via PECL), and RabbitMQ 3.13 or 4.x. On Linux, install `librabbitmq-dev` first. The package does not support `php-amqplib` as a fallback, so ensure your deployment environment meets these requirements.
- How do I configure multi-host failover for RabbitMQ in Laravel?
- Define multiple host entries in your `.env` under `RABBITMQ_HOSTS` (comma-separated). The package automatically handles failover and connection pooling. You can also configure health checks and retry backoff in `config/queue.php` under the `rabbitmq` driver settings.
- Can I use priority queues or delayed messages with this package?
- Yes, both are supported. Enable priority queues by setting `RABBITMQ_PRIORITY=true` in `.env`. For delayed messages, use the `delay()` method on jobs or configure TTL/dead-letter routing in your queue declarations via Artisan commands like `rabbitmq:queue-declare`.
- What’s the difference between `basic_consume` and poll mode for workers?
- `basic_consume` is a high-performance push-based mode (requires tuning, e.g., one queue per worker), while poll mode is pull-based and aligns with Laravel’s default worker behavior. Use `basic_consume` for low-latency needs and poll mode for simplicity. Set `RABBITMQ_WORKER=consume` or leave it unset for poll mode.
- How do I handle failed jobs or dead-letter queues?
- Failed jobs are routed to dead-letter queues by default. Configure dead-letter routing via Artisan commands (`rabbitmq:queue-declare --dead-letter-exchange=...`). Monitor failed jobs using Horizon or manually inspect the dead-letter queue. The package also supports custom failed-job handlers via the `RabbitMQJob` class.
- Is this package compatible with Laravel Octane?
- Yes, it includes Octane support. Set `RABBITMQ_OCTANE_RESET_ON_REQUEST=true` in `.env` to reset the AMQP connection pool on every request, which is useful for Octane’s stateless workers. This ensures clean connections for high-performance scenarios.
- What alternatives exist for RabbitMQ queues in Laravel, and why choose this package?
- Alternatives like `vladimir-yuldashev/laravel-queue-rabbitmq` use `php-amqplib`, which lacks native performance. This package uses `ext-amqp` for lower latency and better resource efficiency. It also offers advanced features like quorum queues, publisher confirms, and tight Horizon/Octane integration, making it ideal for production workloads.
- How do I test RabbitMQ queue jobs in my Laravel application?
- Use Laravel’s built-in queue testing tools with `Queue::fake()`. For RabbitMQ-specific tests, mock the `RabbitMQConnection` interface or use a local RabbitMQ instance (e.g., Docker). The package includes test utilities for verifying message routing, retries, and dead-letter behavior in your test suite.