- Can I use this bundle in Laravel, or is it strictly for Symfony?
- This bundle is designed for Symfony 6.4/7.x and PHP 8.2+, not Laravel. However, if you need similar transaction management in Laravel, you could explore alternatives like Laravel Transactions or Doctrine DBAL for Laravel. The core AEATech Transaction Manager library might be adaptable, but this bundle itself is Symfony-specific.
- How do I set up multiple transaction managers for different databases in Symfony?
- Configure each manager in `aea_tech_transaction_manager.yaml` under the `managers` key, specifying the platform (e.g., `mysql` or `postgresql`) and the connection adapter. For example, define `main` for MySQL and `analytics` for PostgreSQL, each with their own retry policies and connection settings. The bundle supports lazy loading, so managers are initialized only when accessed.
- What if I need to use non-Doctrine databases like MongoDB or Redis?
- This bundle primarily supports Doctrine DBAL, but you can create custom adapters for other databases by extending the adapter interface. However, this requires additional development effort. For non-relational databases, consider whether simpler retry mechanisms or database-specific transactions (e.g., Redis transactions) would suffice instead of a full transaction manager.
- How do I configure retry policies for exponential backoff with jitter?
- In your YAML config, define `retry_policy` under each manager with keys like `max_retries`, `backoff.base_delay_ms`, `backoff.max_delay_ms`, `backoff.multiplier`, and `backoff.jitter_ms`. For example, set `base_delay_ms: 100` and `jitter_ms: 100` to introduce variability in retry delays, reducing thundering herd effects. Defaults are provided, but you can override them per manager.
- Is PHP Attributes autoconfiguration required, or can I stick to YAML?
- PHP Attributes autoconfiguration is optional. You can fully configure the bundle using YAML in `aea_tech_transaction_manager.yaml`. Attributes are useful for domain-specific transaction logic (e.g., custom heuristics or classifiers) but aren’t mandatory. If your team prefers YAML, you can skip Attributes entirely.
- Will this bundle work with Symfony Messenger for transactional message handling?
- Yes, you can wrap Symfony Messenger handlers in transactional contexts using this bundle. While the bundle itself doesn’t integrate directly with Messenger, you can manually invoke transaction managers around message handlers or use middleware to ensure transactions span message processing. This is ideal for event-driven architectures where idempotency is critical.
- How do I test transaction managers in a Symfony application?
- Test transaction managers by mocking the connection adapters (e.g., Doctrine DBAL connections) and verifying transaction rollbacks or commits. Use Symfony’s `TestContainer` or `MockBuilder` to simulate database interactions. For retry policies, test edge cases like failed transactions to ensure retries behave as expected. The bundle’s lazy loading means managers won’t initialize until accessed, so test their initialization paths explicitly.
- What are the performance implications of lazy-loaded transaction managers?
- Lazy loading reduces bootstrapping overhead, which is beneficial for high-concurrency or serverless environments where cold starts are a concern. However, the first access to a manager will incur a slight delay. For high-throughput systems, benchmark the impact of lazy loading versus eager initialization, especially if transaction managers are accessed frequently during startup.
- Does this bundle support distributed transactions (e.g., XA) across multiple databases?
- No, this bundle does not support distributed transactions like XA. It focuses on managing transactions within a single connection or platform-specific transactions (e.g., MySQL or PostgreSQL). For distributed transactions, consider alternatives like Symfony’s `TransactionAwareInterface` combined with compensating transactions or a dedicated distributed transaction manager like Atomikos.
- Are there any known issues or risks with this bundle in production?
- The bundle has minimal community adoption (0 stars, no visible issue tracker), so reliability risks are higher. Key concerns include potential bugs in retry policies under high load or compatibility issues with specific Doctrine DBAL versions. Mitigate risks by forking the repository early or contributing to its development. Always test thoroughly in staging before production deployment.