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

Messenger Heartbeat Bundle Laravel Package

answear/messenger-heartbeat-bundle

Symfony bundle that adds heartbeat/keepalive support to Messenger workers. Install via Composer and run messenger:consume or messenger:failed:retry with --keepalive to keep long-running workers alive and responsive.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony Messenger AMQP Alignment: Perfectly targets the Symfony Messenger AMQP transport layer, addressing a critical pain point—idle connection timeouts—without requiring architectural overhauls. The bundle leverages PNCTL signals (v3.2.0+) for heartbeat, which is a robust, low-level mechanism for maintaining connection liveness.
  • Reliability Enhancement: Mitigates false negatives in monitoring by ensuring workers remain active, reducing message loss and unnecessary retries (critical for event-driven systems). The skip-failure listener (v4.1.0) further prevents message duplication during transport exceptions.
  • Observability: Introduces enhanced logging (v3.2.0) for connection activity, which integrates seamlessly with Symfony’s logging stack. This is invaluable for debugging transient failures without requiring additional tooling.
  • Limited Scope: While effective for AMQP, this bundle is irrelevant for non-AMQP transports (e.g., Redis, Doctrine, HTTP). Ensure your system’s transport strategy aligns with this package’s use case.
  • Symfony Version Dependency: Requires Symfony 7.2+ and PHP 8.4+, which may necessitate upgrade planning if your stack is outdated. The BC breaks (e.g., dropping Symfony 6/7.0/7.1) are intentional but could introduce friction.

Integration Feasibility

  • Zero-Configuration Deployment: Symfony Flex auto-registers the bundle, eliminating manual bundles.php edits. Installation is as simple as:
    composer require answear/messenger-heartbeat-bundle
    
    followed by enabling --keepalive in worker commands.
  • Minimal CLI Adjustment: Only requires adding --keepalive to:
    messenger:consume [options] --keepalive
    messenger:failed:retry [options] --keepalive
    
    No changes to message handlers, services, or routing are needed.
  • Backward Compatibility Risks: The bundle’s BC breaks (e.g., Symfony 6/7.0/7.1 dropped in v3.0.0) mean existing projects must align with its version constraints. If your stack is pre-Symfony 7.2, this package is non-starter.
  • Dependency Stability: Relies on symfony/amqp-messenger and ext-amqp. Ensure these dependencies are actively maintained and compatible with your broker (e.g., RabbitMQ’s PNCTL support).

Technical Risk

  • Heartbeat Efficacy:
    • Risk: While heartbeats prevent idle timeouts, they do not resolve deeper issues like broker crashes or persistent network partitions. Over-reliance on this bundle could mask infrastructure problems.
    • Mitigation: Pair with broker-level health checks (e.g., RabbitMQ’s heartbeat parameter) and monitor connection logs for anomalies.
  • Performance Impact:
    • Risk: Heartbeats introduce minimal overhead (~5% CPU for keepalive pings), but this could amplify under high-throughput scenarios (e.g., 10K+ messages/sec).
    • Mitigation: Benchmark under production-like loads to validate latency/throughput impact.
  • Global Signal Conflicts:
    • Risk: PNCTL signals (v3.2.0+) are global, which could interfere with multi-worker setups (e.g., shared processes in Docker/Kubernetes) or other tools using signals.
    • Mitigation: Test in staging with your worker orchestrator (e.g., Supervisor, Kubernetes) to ensure no signal collisions.
  • Monitoring Gaps:
    • Risk: Without metrics integration (e.g., Prometheus), heartbeat effectiveness is log-dependent. Critical for SREs to correlate connection activity with business outcomes.
    • Mitigation: Export logs to a centralized logging system (e.g., ELK, Datadog) and consider custom metrics for connection.last_activity.

Key Questions

  1. Stack Compatibility:
    • Are you using Symfony 7.2+, PHP 8.4+, and AMQP transport? If not, what are the upgrade paths?
    • Does your AMQP broker (e.g., RabbitMQ) support PNCTL signals? If not, will this bundle still function?
  2. Current Pain Points:
    • Do you experience silent worker failures, message loss, or excessive retries due to idle connections?
    • Are long-running workers (e.g., batch jobs) prone to timeouts?
  3. Operational Workflow:
    • How will you monitor heartbeat effectiveness? (e.g., log aggregation, custom dashboards)
    • Will heartbeats be enabled globally or selectively (e.g., only for critical queues)?
  4. Failure Mode Handling:
    • How will you distinguish between transient network issues and broker failures using this bundle?
    • Do you have fallback mechanisms (e.g., dead-letter queues) for when heartbeats fail?
  5. Alternatives:
    • Have you evaluated native broker heartbeats (e.g., RabbitMQ’s heartbeat parameter) or third-party monitoring tools (e.g., Prometheus AMQP exporter)?
    • Would a custom heartbeat solution (e.g., periodic ping messages) be more flexible for your use case?

Integration Approach

Stack Fit

  • Symfony Ecosystem: Designed for Symfony Messenger AMQP transport, this bundle natively integrates with the framework’s bundle system (Symfony Flex auto-registration). It requires no changes to existing codebases beyond CLI flag adjustments.
  • AMQP Broker Compatibility: Works with any AMQP-compliant broker (e.g., RabbitMQ, Qpid) that supports PNCTL signals. Verify broker-specific configurations (e.g., RabbitMQ’s heartbeat parameter) may need tuning.
  • PHP/PHP Extensions: Requires PHP 8.4+ and the ext-amqp extension. Ensure your runtime environment meets these prerequisites.
  • Symfony Version Lock: Symfony 7.2+ only (v3.0.0+). Projects on older versions (e.g., Symfony 6) must upgrade or seek alternatives.

Migration Path

  1. Pre-Integration Checklist:
    • Upgrade to Symfony 7.2+ and PHP 8.4+ if not already aligned.
    • Verify ext-amqp is installed and compatible with your broker.
    • Audit worker processes to ensure no conflicts with global PNCTL signals (e.g., custom signal handlers).
  2. Installation:
    composer require answear/messenger-heartbeat-bundle
    
    • Symfony Flex auto-registers the bundle in config/bundles.php.
  3. Enable Heartbeat:
    • Modify worker commands to include --keepalive:
      php bin/console messenger:consume [queue] --keepalive
      php bin/console messenger:failed:retry [queue] --keepalive
      
    • For Supervisor/Kubernetes, update process definitions to include the flag.
  4. Validation:
    • Log Analysis: Verify heartbeat logs (e.g., Connection last activity updated) appear in Symfony’s log output.
    • Load Testing: Simulate idle periods to confirm workers do not disconnect.
    • Failure Injection: Trigger network timeouts to ensure recovery behavior is as expected.

Compatibility

  • Symfony Messenger: Tested with AMQP transport only. Other transports (e.g., Redis, Doctrine) are unsupported.
  • Worker Orchestration:
    • Supervisor: Ensure keepalive flag is passed in the command line.
    • Kubernetes: Use args in the container spec to include --keepalive.
    • Docker: Pass the flag via docker run or docker-compose.
  • Custom Workers: If using custom worker classes, confirm they do not override the heartbeat mechanism (unlikely, as this is transport-level).

Sequencing

  1. Upgrade Phase (if needed):
    • Align Symfony/PHP versions to 7.2+/8.4+ before integration.
  2. Staging Validation:
    • Deploy to a non-production environment with --keepalive enabled.
    • Monitor logs for heartbeat activity and worker stability.
  3. Gradual Rollout:
    • Enable heartbeats for non-critical queues first.
    • Expand to high-priority queues after validation.
  4. Monitoring Setup:
    • Configure log aggregation (e.g., ELK, Datadog) to track connection.last_activity.
    • Set up alerts for abnormal heartbeat patterns (e.g., missing p
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor