- How do I switch my Laravel app from database queues to RabbitMQ using this package?
- Update your `.env` file to set `QUEUE_CONNECTION=rabbitmq`, then install the package via `composer require iamfarhad/laravel-rabbitmq`. No code changes are needed—your existing job classes and queue logic remain compatible. Test with `php artisan queue:work` to verify RabbitMQ integration.
- Does this package support Laravel Horizon for monitoring RabbitMQ queues?
- Yes, but Horizon integration requires manual setup. Enable it by setting `RABBITMQ_WORKER=horizon` in your `.env`. The package provides Horizon hooks for monitoring, but you’ll need to configure Horizon’s `config/queue.php` to recognize RabbitMQ-specific metrics like connection health and channel usage.
- What Laravel versions and PHP requirements are supported?
- This package supports Laravel 11.x, 12.x, and 13.x with PHP 8.2 or higher. RabbitMQ 3.13+ is officially tested, though 3.8–3.12 may work with best-effort compatibility. Always check the [SUPPORT.md](https://github.com/iamfarhad/LaravelRabbitMQ/blob/main/SUPPORT.md) for version-specific notes.
- How does connection pooling work, and can I configure it for high traffic?
- The package uses `ext-amqp` for connection pooling with configurable limits via `rabbitmq.pool` settings in `config/queue.php`. Adjust `max_connections` and `max_channels` based on your workload. For high traffic, enable `RABBITMQ_CONNECTION_HEALTH_CHECK` to auto-reconnect stale connections.
- Can I use priority queues or delayed messages with this driver?
- Yes, the package supports priority queues via `priority` job options and delayed messages using `delay()` or `after()` methods. Configure these in your job class or via queue options. For delayed messages, ensure your RabbitMQ server has the `rabbitmq_delayed_message_exchange` plugin enabled.
- What’s the difference between `basic_consume` mode and the default worker mode?
- `basic_consume` mode (enabled via `RABBITMQ_CONSUME_MODE=consume`) offers lower latency by bypassing Laravel’s queue worker overhead, ideal for high-throughput scenarios. The default mode uses Laravel’s queue worker for broader compatibility. Test both modes in staging to measure performance impact.
- How do I handle failed jobs or dead-letter queues (DLQ) in RabbitMQ?
- Configure dead-letter exchanges and queues via the `rabbitmq:declare` Artisan command or `config/queue.php`. Failed jobs are routed to the DLQ by default, but you can customize this with `failed()` middleware or `onFailure()` in your job class. Monitor DLQs using `rabbitmq:view` commands.
- Is this package compatible with Laravel Octane, and how do I reset connections?
- Yes, Octane compatibility is supported. Enable safe pool resets by setting `RABBITMQ_OCTANE_RESET_ON_REQUEST=true` in `.env`. This ensures connections are reset per request without disrupting active workers, reducing memory leaks in long-running Octane processes.
- What alternatives exist for RabbitMQ queues in Laravel, and why choose this package?
- Alternatives include `vladimir-yuldashev/laravel-queue-rabbitmq` (older, less maintained) or self-built solutions using `php-amqplib`. This package stands out for its native Laravel Queue API compatibility, built-in connection pooling, Horizon/Octane hooks, and production-ready features like publisher confirms and transactions.
- How do I test RabbitMQ queue jobs in my Laravel application?
- Use Laravel’s built-in queue assertions (e.g., `expectsJobs(Job::class)`) or mock the RabbitMQ connection in tests by overriding `config/queue.php` to point to an in-memory queue during testing. For integration tests, spin up a local RabbitMQ instance via Docker or use `rabbitmq:purge` to reset queues between tests.