- How do I integrate enqueue/amqp-lib with Laravel’s queue system?
- Use the **enqueue/laravel** bridge to connect Enqueue to Laravel’s queue system. Configure the AMQP transport in `config/queue.php` under the `connections` array, specifying the `amqp-lib` transport and a valid AMQP DSN (e.g., `amqp://user:pass@rabbitmq:5672/%2f`). Ensure your Laravel jobs are serializable, as AMQP requires this for message passing.
- Which Laravel versions are compatible with enqueue/amqp-lib?
- The package works with **Laravel 8.x, 9.x, and 10.x** via the Enqueue bridge. For older versions (7.x), check the Enqueue documentation for compatibility notes. The transport itself is framework-agnostic but relies on Enqueue’s Laravel integration, which handles version-specific quirks.
- Can I use enqueue/amqp-lib without Laravel (standalone PHP)?
- Yes. The package is part of the **Enqueue ecosystem** and can be used independently for AMQP-based messaging (e.g., pub/sub, RPC). Install via Composer (`enqueue/amqp-lib`) and configure it in an Enqueue context. Example use cases include microservices or custom event-driven workflows outside Laravel.
- What AMQP brokers does enqueue/amqp-lib support?
- It primarily supports **RabbitMQ** (most tested) and other **AMQP 0-9-1 compliant brokers** like Qpid or Apache Qpid Dispatch. For brokers with non-standard extensions (e.g., RabbitMQ’s federation), consult the [php-amqplib docs](https://github.com/php-amqplib/php-amqplib) for compatibility. SSL/TLS and authentication (e.g., SASL) are configurable.
- How do I handle message retries or dead-letter queues in Laravel with AMQP?
- Leverage Enqueue’s **retry mechanism** and Laravel’s built-in retry logic. Configure the `options` array in your queue connection to include `retry_strategy` (e.g., `max_attempts`). For dead-letter queues, use RabbitMQ’s native dead-letter exchange or Enqueue’s `dead_letter_exchange` option in the transport configuration.
- Is enqueue/amqp-lib production-ready? Any known stability issues?
- Yes, it’s production-ready and widely used in high-traffic systems. However, monitor **connection timeouts** (tune `connection_timeout` in DSN) and **prefetch counts** (set via `options['prefetch_count']`) to avoid consumer overload. Test failover scenarios if using clustered brokers, as AMQP connections are stateful.
- How does enqueue/amqp-lib compare to Laravel’s built-in Redis/SQL queue drivers?
- Unlike Redis/SQL drivers, AMQP offers **pub/sub, RPC, and advanced routing** (exchanges/bindings) for complex workflows. It’s better for **distributed systems** but adds network latency. For simple job queues, Redis/SQL may suffice; AMQP shines in **event-driven architectures** or when integrating with other AMQP-based services.
- Can I monitor AMQP queue metrics (e.g., message depth, consumer lag) in Laravel?
- Yes, use **RabbitMQ’s Management Plugin** (HTTP API) or tools like **Prometheus + Grafana** with the `rabbitmq_exporter`. For Laravel-specific metrics, extend Enqueue’s context to log queue stats or integrate with monitoring libraries like `spatie/laravel-monitoring`. The transport itself doesn’t include built-in metrics but exposes AMQP’s native stats.
- What’s the performance overhead of AMQP vs. in-memory queues (e.g., sync) in Laravel?
- AMQP introduces **network latency** (10–100ms per message, depending on broker distance) compared to in-memory queues (microseconds). For high-throughput systems, optimize with **connection pooling** (php-amqplib’s `persistent_connections`) and **batch processing**. Benchmark with tools like `ab` or `k6` to compare against Redis/SQL drivers.
- How do I debug connection issues or message loss in enqueue/amqp-lib?
- Enable **debug logging** in php-amqplib via `options['log_level'] = LOG_DEBUG`. Check RabbitMQ logs for broker-side errors. Use Enqueue’s `Context` to inspect message flow. For message loss, verify **persistence settings** (AMQP messages must be durable/non-transient) and **consumer acknowledgments** (set `acknowledge_mode` to `manual` if needed).