- How do I use enqueue/stomp with Laravel’s queue system?
- Use Laravel’s `Queue::extend()` to register the STOMP transport. Configure a DSN (e.g., `stomp://user:pass@host:port`) in `config/queue.php` under the `stomp` driver. Then dispatch jobs with `Queue::dispatch()` or use `queue:work` to process them. Ensure your STOMP broker (e.g., RabbitMQ) is running and accessible.
- Does enqueue/stomp support delayed jobs like Laravel’s default queue?
- Yes, but you must configure the STOMP broker to support delayed messages (e.g., RabbitMQ’s `x-delay` header). Laravel’s `delay()` method will work if the broker supports it. Test with a small delay first to verify behavior, as STOMP brokers may handle delays differently than Redis or database queues.
- What Laravel versions and PHP versions does enqueue/stomp support?
- The package supports Laravel 9+ and requires PHP 8.1+. It adheres to Queue Interop, so it integrates seamlessly with Laravel’s queue system without version-specific hacks. Check the [Enqueue documentation](https://php-enqueue.github.io/transport/stomp/) for minor version compatibility notes.
- How do I handle failed jobs with enqueue/stomp in Laravel?
- Laravel’s `queue:failed-table` won’t work with STOMP. Configure a dead-letter queue (DLQ) in your STOMP broker to route failed messages. Use the broker’s management UI (e.g., RabbitMQ’s) or a custom consumer to process failed jobs. For retries, implement logic in your consumer or use the broker’s built-in retry policies.
- Can I use enqueue/stomp with RabbitMQ’s AMQP plugin instead of STOMP?
- No, this package is specifically for STOMP protocol. For RabbitMQ, consider `enqueue/amqp-ext` (AMQP 0-9-1) or `php-amqplib` for direct AMQP integration. STOMP is useful if you need cross-language support (e.g., Java services) or if your broker only exposes STOMP (e.g., some cloud providers).
- How do I secure STOMP connections in production?
- Use TLS/SSL for STOMP connections (e.g., `stomps://` instead of `stomp://`). Store credentials in Laravel’s `.env` file (e.g., `QUEUE_STOMP_DSN=stomps://user:pass@host:port`). Avoid hardcoding secrets. For authentication, ensure your broker supports SASL or basic auth securely. Monitor for unauthorized access via broker logs.
- What are the performance implications of using STOMP vs. Redis or database queues?
- STOMP introduces network overhead compared to in-memory Redis or database queues. Benchmark your workload, especially for high-throughput apps. STOMP shines in distributed environments where cross-language messaging or advanced routing (e.g., topics, headers) are needed. For Laravel, test with `queue:work --sleep=3` to simulate load.
- How do I monitor job progress or failures with enqueue/stomp?
- Use your STOMP broker’s management tools (e.g., RabbitMQ’s web UI, ActiveMQ’s console). For custom metrics, integrate Prometheus via the broker’s plugin or log job events to a monitoring system. Laravel’s `queue:failed` command won’t work; instead, poll the DLQ or broker queues programmatically for errors.
- Are there alternatives to enqueue/stomp for Laravel STOMP integration?
- For Laravel, alternatives include `php-stomp` (low-level client) or `laravel/queue` with Redis/RabbitMQ AMQP drivers. If you need STOMP specifically, `enqueue/stomp` is the most Laravel-friendly option due to Queue Interop compliance. For pure PHP STOMP, `stomp-php/stomp-php` is another choice but lacks Laravel integration helpers.
- How do I test enqueue/stomp locally before deploying to production?
- Use a local STOMP broker like RabbitMQ with Docker (`docker run -d --name rabbitmq -p 61613:61613 rabbitmq:3`). Configure the broker’s STOMP plugin (e.g., `rabbitmq-stomp`). Test with a simple consumer/producer script, then integrate with Laravel’s `queue:work`. Mock failures by sending malformed messages to verify DLQ handling.