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

Async Laravel Package

aescarcha/async

Symfony bundle that listens to Doctrine entity lifecycle events (persist/update/remove) and publishes RabbitMQ jobs so heavy processing runs asynchronously. Configure via OldSoundRabbitMq and register the persist listener as consumer/event subscriber.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Async Processing: The bundle leverages Symfony’s event system (e.g., prePersist, preRemove) to offload heavy operations (e.g., entity serialization/deserialization, post-save logic) to a RabbitMQ (RMQ) queue. This aligns well with architectures requiring decoupled, scalable background tasks (e.g., data sync, notifications, or resource-intensive computations).
  • Symfony Serializer Integration: Acts as a wrapper over Symfony’s SerializerComponent, ensuring consistency in entity serialization/deserialization. Useful for APIs or systems where entities must persist in a normalized format (e.g., Elasticsearch, caches).
  • Limited Scope: Focuses only on entity events (no general-purpose async task queue). Not a replacement for tools like Symfony Messenger or Enqueue, but a niche solution for entity lifecycle async operations.

Integration Feasibility

  • Symfony Dependency: Tightly coupled to Symfony’s ecosystem (events, Serializer, old_sound_rabbit_mq). Non-Symfony PHP/Laravel projects will require significant abstraction (e.g., rewriting listeners or using a bridge like php-amqplib directly).
  • RabbitMQ Requirement: Mandates RMQ setup (connections, exchanges, queues). Adds operational complexity if RMQ isn’t already in use.
  • Laravel Adaptability:
    • Event System: Laravel’s events can be mapped to Symfony’s listeners (e.g., eloquent.savingprePersist).
    • Queue System: Laravel’s queue workers (e.g., php artisan queue:work) can consume RMQ messages if configured via php-amqplib or a bridge like vladimir-yuldashev/laravel-queue-rabbitmq.
    • Serializer: Laravel’s Illuminate\Support\Facades\Serializer or spatie/laravel-serializable-traits can replace Symfony’s Serializer with minimal effort.

Technical Risk

  • Bundle Maturity: No stars/dependents or tests indicate high risk of undocumented bugs or breaking changes. Requires thorough validation.
  • RMQ Configuration: Misconfigured RMQ (e.g., wrong exchange/queue names, ACLs) can lead to silent failures or message loss.
  • Serialization Edge Cases: Custom entity properties (e.g., circular references, non-serializable types) may break silently without proper error handling.
  • Laravel-Specific Gaps:
    • No native support for Laravel’s Eloquent lifecycle events (e.g., retrieved, saved).
    • No built-in retry logic for failed jobs (unlike Laravel’s queue system).

Key Questions

  1. Why Async for Serialization?
    • Is the bottleneck I/O-bound (e.g., API calls, DB writes) or CPU-bound (e.g., complex transformations)? If the latter, consider Laravel’s process queue driver instead.
  2. RMQ vs. Laravel Queues:
    • Does the team already use RMQ? If not, Laravel’s native queues (Redis, database) may be simpler.
  3. Entity Complexity:
    • Are entities simple (e.g., CRUD) or complex (e.g., nested, polymorphic)? Complex cases may need custom serializers.
  4. Error Handling:
    • How will failed async jobs be monitored/recovered? (No built-in dead-letter queue or retry in this bundle.)
  5. Alternatives:
    • Could Laravel’s observers, model events, or spatie/laravel-activitylog achieve similar goals with less overhead?

Integration Approach

Stack Fit

  • Symfony: Native fit; minimal changes needed beyond RMQ setup.
  • Laravel:
    • Event System: Replace Symfony listeners with Laravel’s ModelObserver or EventServiceProvider.
    • Queue System: Use vladimir-yuldashev/laravel-queue-rabbitmq to bridge RMQ with Laravel’s queue workers.
    • Serializer: Replace Symfony’s Serializer with Laravel’s Serializer facade or spatie/laravel-serializable-traits.
  • Non-Framework PHP: Requires manual implementation of event listeners and RMQ consumers (high effort).

Migration Path

  1. Phase 1: Proof of Concept
    • Set up RMQ locally and test basic entity events (e.g., prePersist).
    • Validate serialization/deserialization for critical entities.
  2. Phase 2: Laravel Adaptation
    • Replace Symfony listeners with Laravel observers:
      // app/Observers/EntityObserver.php
      class EntityObserver {
          public function saving($model) {
              // Push to RMQ via custom queue job
              AsyncJob::dispatch($model)->onConnection('rabbitmq');
          }
      }
      
    • Configure vladimir-yuldashev/laravel-queue-rabbitmq to use the same exchange/queue as the bundle.
  3. Phase 3: Full Integration
    • Migrate all entity events (e.g., deleting, updating) to async jobs.
    • Add monitoring for RMQ consumers (e.g., Laravel Horizon or custom health checks).

Compatibility

  • Symfony Components: High compatibility if using Symfony’s Serializer and old_sound_rabbit_mq.
  • Laravel: Medium compatibility; requires bridging packages and custom event mapping.
  • PHP Version: Requires PHP 5.4+ (due to php-amqplib v2.4.1). Laravel 8+ supports this.
  • Database: No direct DB dependency, but async jobs may interact with DB (e.g., post-save logic).

Sequencing

  1. Setup RMQ: Configure old_sound_rabbit_mq or laravel-queue-rabbitmq.
  2. Define Async Jobs: Create Laravel queue jobs to handle serialized entity data.
  3. Register Observers: Attach observers to Eloquent models for event triggering.
  4. Test Critical Paths: Validate serialization, job processing, and error scenarios.
  5. Monitor: Implement logging for RMQ consumers and job failures.

Operational Impact

Maintenance

  • Bundle Updates: Risk of breaking changes due to low maturity. Pin version strictly in composer.json.
  • RMQ Management:
    • Requires monitoring for connection drops, queue backlogs, or consumer crashes.
    • Need to handle RMQ-specific issues (e.g., prefetch counts, consumer restarts).
  • Laravel-Specific:
    • Custom observers/jobs may need updates if Laravel core changes (e.g., event system).
    • Serializer configurations may diverge from Symfony’s defaults.

Support

  • Debugging:
    • Async failures are harder to trace (e.g., RMQ messages lost, consumer crashes).
    • No built-in logging for job payloads; requires custom instrumentation.
  • Dependency Support:
    • old_sound_rabbit_mq is unmaintained (last commit 2017). Consider php-amqplib directly or enqueue/rabbitmq.
    • Symfony Serializer may behave differently than Laravel’s implementations.
  • Team Skills:
    • Requires familiarity with RMQ, Symfony events, and Laravel’s queue system.

Scaling

  • Horizontal Scaling:
    • RMQ consumers can scale by adding more workers (Laravel’s queue:work --daemon).
    • Ensure exchange/queue configurations support high throughput (e.g., prefetch counts, persistent connections).
  • Performance Bottlenecks:
    • Serialization overhead may negate async benefits for simple entities.
    • RMQ network latency could impact real-time requirements (e.g., UI feedback).
  • Cost:
    • Self-hosted RMQ adds operational overhead (clustering, backups).
    • Cloud RMQ (e.g., AWS SQS, RabbitMQ Cloud) may incur costs.

Failure Modes

Failure Scenario Impact Mitigation
RMQ Broker Down Async jobs fail silently; entities may appear "stuck" in transition. Implement retry logic in jobs; use dead-letter queues.
Consumer Crashes Unprocessed messages pile up; eventual consistency breaks. Monitor consumer health; use supervisor to auto-restart workers.
Serialization Errors Invalid data written to storage or downstream systems. Validate serialized data before processing; log failures.
Network Partition (RMQ ↔ Workers) Workers unable to pull messages; delayed processing. Use persistent connections; implement local retries.
Laravel Queue Worker Fails Jobs accumulate; system slows down. Use queue:failed table; implement job backoff.

Ramp-Up

  • Learning Curve:
    • Moderate: Requires understanding of RMQ, Symfony events, and Laravel’s queue system.
    • High: If team lacks RMQ experience, expect delays in troubleshooting.
  • Documentation Gaps:
    • Bundle lacks examples for Laravel integration or error handling.
    • RMQ tuning (e.g., prefetch, QoS) requires external research.
  • Onboarding Steps:
    1. Setup RMQ: Document connection strings, exchange/
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony