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

Simple Bus On Steroids Laravel Package

cleancode/simple-bus-on-steroids

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Alignment: The package aligns well with Laravel’s event system and asynchronous workflows, particularly for use cases requiring event sourcing, transactional integrity, and reliable event processing.
  • Database-Backed Queues: The "async rabbit pattern" (pushing events from DB to RabbitMQ) introduces a hybrid persistence model, which may conflict with Laravel’s native queue drivers (e.g., Redis, database). This could complicate deployment if the team relies on Laravel’s built-in queue abstractions.
  • Transactional Guarantees: The per-subscriber transaction model ensures isolation but may introduce performance overhead if subscribers are I/O-bound (e.g., external API calls). This could impact throughput in high-volume systems.
  • Event Metadata: The addition of event_id, correlation_id, parent_id, and occurrence_time is valuable for auditing, debugging, and event sourcing, but requires schema changes and potential adjustments to existing event structures.

Integration Feasibility

  • Laravel Compatibility:
    • Pros: Works with Laravel’s event system (Event::dispatch()) and supports queue workers (php artisan queue:work).
    • Cons: Requires RabbitMQ (not a default Laravel dependency), which may necessitate additional infrastructure setup.
    • Database Schema: The package expects events to be stored in a database table (likely events), which may conflict with Laravel’s existing event storage (if using events table for logging).
  • Dependency Overhead:
    • Introduces SimpleBus (a separate event bus library) and RabbitMQ, increasing complexity for teams unfamiliar with these tools.
    • May require custom middleware or service providers to bridge Laravel’s event system with SimpleBus.

Technical Risk

  • Schema Conflicts: The package’s reliance on a custom events table could clash with Laravel’s default event logging or third-party packages (e.g., spatie/laravel-activitylog).
  • RabbitMQ Dependency: Adds operational complexity (clustering, monitoring, failover) that may not be justified for low-to-medium traffic applications.
  • Transaction Isolation: Per-subscriber transactions could lead to lock contention in high-throughput systems, especially if subscribers perform long-running operations.
  • Dead Letter Queue (DLQ) Handling: Requires additional infrastructure (e.g., a separate DLQ consumer) and monitoring for failed events.
  • Testing Complexity: Asynchronous event flows with transactions and retries introduce flakiness in tests, requiring robust test doubles or mocking strategies.

Key Questions

  1. Why RabbitMQ?
    • Does the team already use RabbitMQ, or is this introducing unnecessary complexity? Could Laravel’s native queue drivers (Redis, database) suffice with retries?
  2. Event Storage Strategy
    • How will this interact with Laravel’s existing event logging (if any)? Will events be duplicated?
  3. Performance Trade-offs
    • What is the expected volume of events/subcribers? Will per-subscriber transactions impact latency?
  4. Failure Recovery
    • How will dead-lettered events be monitored and resolved? Is there a fallback mechanism for RabbitMQ failures?
  5. Migration Path
    • Can this be incrementally adopted (e.g., start with critical event types), or is a big-bang migration required?
  6. Observability
    • How will event metadata (correlation IDs, timestamps) be surfaced in logs/monitoring tools (e.g., Sentry, Datadog)?

Integration Approach

Stack Fit

  • Best For:
    • Event Sourcing architectures where event integrity is critical.
    • Systems requiring auditable event flows (e.g., financial transactions, workflows).
    • Teams already using RabbitMQ or willing to adopt it for async processing.
  • Less Ideal For:
    • Simple CRUD applications with minimal async requirements.
    • Teams without experience in event-driven design or message brokers.
    • Projects where low latency is prioritized over transactional guarantees.

Migration Path

  1. Assessment Phase:
    • Audit existing event usage (types, subscribers, current queue drivers).
    • Identify critical event flows that would benefit from transactions/retries.
  2. Proof of Concept (PoC):
    • Implement a subset of events with the package to test:
      • Schema compatibility (custom events table).
      • RabbitMQ integration (connection, consumers).
      • Transaction behavior (success/failure scenarios).
  3. Incremental Rollout:
    • Phase 1: Replace Laravel’s queue driver for non-critical events with the package’s hybrid DB/RabbitMQ approach.
    • Phase 2: Add transactional subscribers for high-priority event types.
    • Phase 3: Enable DLQ and retry logic for production-grade reliability.
  4. Fallback Plan:
    • Maintain a parallel queue driver (e.g., Redis) for events not yet migrated to avoid blocking deployments.

Compatibility

  • Laravel Event System:
    • The package can be integrated via event listeners or service providers, but requires wrapping Laravel’s Event::dispatch() to use SimpleBus.
    • Example:
      // In a service provider:
      $eventBus = new SimpleBusOnSteroidsBus();
      Event::macro('dispatchWithBus', function ($event) use ($eventBus) {
          $eventBus->publish($event);
      });
      
  • Queue Workers:
    • Replace php artisan queue:work with a custom consumer that pulls from RabbitMQ (or use Laravel’s queue workers with a bridge).
  • Database Schema:
    • The package expects a table like:
      CREATE TABLE events (
          id BIGINT AUTO_INCREMENT PRIMARY KEY,
          event_id VARCHAR(255),
          correlation_id VARCHAR(255),
          parent_id VARCHAR(255),
          occurrence_time DATETIME,
          payload TEXT,
          status VARCHAR(50),
          -- other metadata
      );
      
    • May require migrations to avoid conflicts with Laravel’s events table.

Sequencing

  1. Infrastructure Setup:
    • Deploy RabbitMQ (or use an existing cluster).
    • Configure DLQ and retry policies.
  2. Code Changes:
    • Install the package (composer require cleancode/simple-bus-on-steroids).
    • Extend Laravel’s event system to use SimpleBus.
    • Update subscribers to handle the enriched event metadata.
  3. Testing:
    • Write integration tests for event flows (including failures).
    • Test RabbitMQ connectivity and DLQ behavior.
  4. Monitoring:
    • Instrument event processing with metrics (e.g., processing time, failure rates).
    • Set up alerts for DLQ events.

Operational Impact

Maintenance

  • Schema Management:
    • The custom events table requires migrations and may need updates if the package evolves.
    • Backup strategy must account for event data persistence.
  • Dependency Updates:
    • SimpleBus and RabbitMQ clients may require frequent updates, introducing compatibility risks.
  • Configuration Overhead:
    • Retry policies, DLQ settings, and RabbitMQ connections need centralized configuration (e.g., .env or config files).

Support

  • Debugging Complexity:
    • Event flows with transactions, retries, and distributed tracing (RabbitMQ) will require advanced logging (e.g., structured logs with correlation IDs).
    • Tools like Laravel Horizon may need extensions to monitor RabbitMQ queues.
  • Team Skills:
    • Engineers must be proficient in event-driven architecture, message brokers, and distributed transactions.
    • Lack of documentation (low stars, minimal README) may require internal knowledge sharing.

Scaling

  • Horizontal Scaling:
    • RabbitMQ consumers can scale horizontally, but database locks (from per-subscriber transactions) may become a bottleneck.
    • Consider read replicas for the events table if scaling writes.
  • Throughput:
    • Per-subscriber transactions add latency. Benchmark with expected load to avoid bottlenecks.
    • RabbitMQ’s prefetch count and concurrency settings must be tuned.
  • Resource Usage:
    • RabbitMQ and database I/O will increase with event volume. Monitor CPU, memory, and disk usage.

Failure Modes

Failure Scenario Impact Mitigation
RabbitMQ Unavailable Events stall in DB or are lost. Fallback to Laravel’s queue driver; use a circuit breaker.
Database Connection Issues Events not persisted; transactions fail. Retry logic with exponential backoff; monitor DB health.
Subscriber Crashes Partial event processing; DLQ overflow. Configure max retries and DLQ alerts; implement circuit breakers.
Schema Corruption Event metadata becomes inconsistent. Regular backups; use migrations carefully.
High Event Volume Database locks; RabbitMQ overload. Optimize transaction isolation; scale RabbitMQ/consumers.
Missing Correlation IDs Debugging event flows becomes difficult. Enforce metadata in all events
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui