Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Rabbitmq Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • High Compatibility: Fully integrates with Laravel’s native queue system, replacing the default 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.
  • Production-Grade Features: Supports advanced RabbitMQ features like quorum queues, priority queues, dead-letter routing, publisher confirms, and multi-host failover, making it ideal for scalable, fault-tolerant systems.
  • Horizon & Octane Support: Seamlessly integrates with Laravel Horizon (for monitoring) and Octane (for high-performance workers), reducing friction for teams already using these tools.
  • Extensibility: Custom job classes (RabbitMQJob) allow access to raw RabbitMQ messages, enabling use cases like non-JSON payloads or custom serialization.

Integration Feasibility

  • Minimal Code Changes: Replaces QUEUE_CONNECTION=database with QUEUE_CONNECTION=rabbitmq in .env. Existing job classes (App\Jobs\*) require no modifications unless leveraging raw RabbitMQ features.
  • Configuration-Driven: Most features (e.g., quorum queues, delayed messages) are enabled via .env or config/queue.php, reducing runtime complexity.
  • Artisan Commands: Provides CLI tools for queue/exchange management (rabbitmq:queue-declare, rabbitmq:pool-stats), easing operational tasks.
  • Dependency: Requires 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.

Technical Risk

  • 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.
  • Complexity for Simple Use Cases: Overkill for low-throughput applications; adds operational overhead (RabbitMQ cluster management, connection pooling tuning).
  • Worker Process Management: 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.
  • Horizon/Octane Guard Clauses: Features like Horizon integration are opt-in and may introduce subtle bugs if misconfigured (e.g., missing RABBITMQ_WORKER=horizon).
  • Delayed Messages: Relies on either TTL/dead-letter routing or the RabbitMQ delayed-message plugin, which may not be available in all deployments.

Key Questions

  1. Infrastructure Readiness:
    • Can the deployment environment support ext-amqp (PECL, system libraries)?
    • Is RabbitMQ 3.13+ available, or will best-effort support for older versions suffice?
  2. Scaling Requirements:
    • Will the application use multi-host failover? If so, how will connection pooling and health checks be tuned?
    • Are quorum queues or priority queues needed, or will default FIFO queues suffice?
  3. Operational Overhead:
    • Who will manage RabbitMQ clusters, backups, and monitoring?
    • How will dead-letter queues and failed messages be handled (e.g., alerts, reprocessing)?
  4. Worker Strategy:
    • Should workers use poll (safe, Laravel-compatible) or consume (high-performance, requires tuning) mode?
    • Will Supervisor/systemd/Kubernetes be used to manage worker processes?
  5. Horizon/Octane:
    • Is Horizon already in use? If not, is the added complexity justified?
    • For Octane, should the AMQP pool reset on every request (RABBITMQ_OCTANE_RESET_ON_REQUEST=true)?

Integration Approach

Stack Fit

  • Laravel 10–13: Native support with zero breaking changes to the queue API.
  • PHP 8.2+: Required for ext-amqp compatibility and modern Laravel features.
  • RabbitMQ 3.13/4.x: Primary support; older versions (3.8–3.12) are best-effort.
  • Horizon/Octane: Optional but tightly integrated. Horizon requires explicit configuration (RABBITMQ_WORKER=horizon).
  • Database: No direct dependency, but after_commit queue behavior (via RABBITMQ_AFTER_COMMIT=true) may interact with transactional email/job workflows.

Migration Path

  1. Preparation:
    • Install ext-amqp and system dependencies (e.g., librabbitmq-dev).
    • Deploy RabbitMQ 3.13+ (cluster recommended for production).
    • Configure .env:
      QUEUE_CONNECTION=rabbitmq
      RABBITMQ_HOST=rabbitmq.example.com
      RABBITMQ_USER=laravel
      RABBITMQ_PASSWORD=...
      
  2. Testing:
    • Start with a non-production queue (e.g., test-queue) to validate jobs dispatch and consume correctly.
    • Test delayed jobs, failed job rerouting, and multi-host failover in staging.
  3. Phased Rollout:
    • Phase 1: Migrate low-priority queues (e.g., emails, logs) to RabbitMQ.
    • Phase 2: Enable advanced features (quorum queues, publisher confirms) and monitor performance.
    • Phase 3: Replace remaining queues; decommission old queue drivers.
  4. Worker Transition:
    • Replace php artisan queue:work with php artisan rabbitmq:consume (or keep using Laravel’s worker with QUEUE_CONNECTION=rabbitmq).
    • Tune --num-processes, --memory, and --timeout based on queue load.

Compatibility

  • Backward Compatibility: Jobs dispatched via dispatch(new Job) or bus()->dispatch() work unchanged.
  • Horizon: Existing Horizon dashboards and events continue to work if RABBITMQ_WORKER=horizon is set.
  • Octane: AMQP pool reuse improves performance; disable with RABBITMQ_OCTANE_RESET_ON_REQUEST=true if needed.
  • Third-Party Packages: Most Laravel queue-aware packages (e.g., spatie/laravel-queue-scheduler) will work without changes.

Sequencing

  1. Infrastructure First: Deploy and test RabbitMQ before code changes.
  2. Configuration: Publish the package config (php artisan vendor:publish --tag=config) and customize config/queue.php.
  3. Job Testing: Verify jobs dispatch and consume correctly in a staging environment.
  4. Monitoring: Set up RabbitMQ management UI (port 15672) and monitor queue lengths, consumer metrics, and failures.
  5. Feature Enablement: Gradually enable advanced features (e.g., quorum queues, dead-letter routing) based on observability data.

Operational Impact

Maintenance

  • RabbitMQ Cluster: Requires ongoing management (backups, node scaling, plugin updates). Teams without RabbitMQ expertise may need to upskill or hire specialists.
  • Connection Pooling: Tuning RABBITMQ_MAX_CONNECTIONS, RABBITMQ_MAX_CHANNELS_PER_CONNECTION, and health checks (RABBITMQ_HEALTH_CHECK_INTERVAL) may be needed for stability.
  • Artisan Commands: Regular use of rabbitmq:pool-stats, rabbitmq:queue-purge, and rabbitmq:exchange-declare will be necessary for maintenance.
  • Dependency Updates: Monitor ext-amqp and RabbitMQ version compatibility; upgrades may require testing.

Support

  • Troubleshooting: Debugging RabbitMQ issues (e.g., connection drops, channel overflows) requires familiarity with AMQP protocols and Laravel’s queue lifecycle.
  • Failed Jobs: Dead-letter queues must be monitored; failed jobs may need manual reprocessing or alerting.
  • Horizon Integration: If using Horizon, ensure the failed_jobs table is properly configured and monitored.
  • Community: Limited stars (34) and dependents (0) suggest a niche audience; support may require self-service or vendor engagement.

Scaling

  • Horizontal Scaling: RabbitMQ’s multi-host failover enables adding more brokers for throughput. Connection pooling (RABBITMQ_MAX_CONNECTIONS) should scale with worker count.
  • Worker Scaling: Use consume mode with one queue per worker process; scale by adding more workers (Supervisor/systemd/Kubernetes).
  • Throughput: Benchmark under load; consume mode offers higher throughput than poll but requires tuning prefetch counts (RABBITMQ_PREFETCH_COUNT).
  • Resource Limits: Monitor memory usage (--memory flag) and timeouts (RABBITMQ_READ_TIMEOUT) to avoid worker crashes.

Failure Modes

Failure Scenario Impact Mitigation
RabbitMQ broker down Jobs stall; workers disconnect.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata