- How do I install the Messenger Heartbeat Bundle for Laravel/Symfony?
- Run `composer require answear/messenger-heartbeat-bundle`—Symfony Flex auto-registers the bundle in `config/bundles.php`. No manual configuration is needed beyond adding `--keepalive` to your worker commands.
- Does this bundle work with Laravel’s Messenger component?
- No, this bundle is designed for Symfony’s Messenger with AMQP transport. Laravel users must use a compatible Symfony-based setup or explore alternatives like `php-amqplib` extensions for heartbeat support.
- What Laravel/Symfony versions are supported?
- The bundle requires **Symfony 7.2+** and **PHP 8.4+**. If your project uses older versions, you’ll need to upgrade or seek alternatives, as earlier Symfony 6/7.x versions are unsupported.
- How do I enable heartbeat for my Messenger workers?
- Add `--keepalive` to your existing commands: `php bin/console messenger:consume --keepalive` or `php bin/console messenger:failed:retry --keepalive`. No other changes are required.
- Will this bundle prevent message loss during idle timeouts?
- Yes, the heartbeat mechanism sends periodic PNCTL signals to keep AMQP connections alive, reducing false timeouts and message loss. However, it won’t resolve broker-level failures (e.g., RabbitMQ crashes).
- Does this work with RabbitMQ or other AMQP brokers?
- It works with any AMQP broker supporting **PNCTL signals** (e.g., RabbitMQ). Ensure your broker’s `heartbeat` parameter is configured to match the bundle’s defaults (e.g., `5` seconds) for optimal reliability.
- Can I use this with Docker/Kubernetes for multi-worker setups?
- Yes, but test in staging first. PNCTL signals are global, so shared processes (e.g., in Docker) or other tools using signals may cause conflicts. Monitor for signal collisions in orchestrated environments.
- How do I monitor heartbeat effectiveness in production?
- Enable Symfony’s logging to track connection activity. For deeper observability, export logs to a centralized system (e.g., ELK, Datadog) or implement custom metrics for `connection.last_activity` timestamps.
- Are there performance impacts from using heartbeat?
- Minimal—heartbeats add ~5% CPU overhead for keepalive pings. Under high-throughput scenarios (e.g., 10K+ messages/sec), benchmark to ensure latency/throughput isn’t affected.
- What alternatives exist if I can’t upgrade to Symfony 7.2+?
- For older Symfony versions, consider custom solutions like **php-amqplib** extensions with manual heartbeat logic or third-party packages like `enqueue/amqp-ext`. Laravel users may need to integrate AMQP libraries directly.