- How do I replace Laravel Queues with ecotone/dbal for async jobs?
- Install via `composer require ecotone/dbal`, then annotate your job handlers with `#[CommandHandler]`. Configure a DBAL channel in `ecotone.php` and dispatch messages with `bus->dispatch()`. Unlike Laravel Queues, this stores messages in your DB tables (e.g., `ecotone_messages`) and supports retries via dead-letter queues.
- Will ecotone/dbal work with Laravel’s Eloquent or only Doctrine ORM?
- It works with *both*—Eloquent and Doctrine ORM. The package uses Doctrine DBAL under the hood, so it’s ORM-agnostic. You can even use raw PDO if needed. Just ensure your DB connection is configured in Laravel’s `config/database.php`.
- What Laravel versions does ecotone/dbal support?
- The package supports Laravel 9.x and 10.x (PHP 8.1+). Check the [Ecotone compatibility table](https://ecotone.tech/docs/laravel) for exact version mappings. If you’re on Laravel 8, you’ll need to pin dependencies manually, as Ecotone dropped official support.
- How do I handle failed messages in production? Can I replay them?
- Failed messages go to the dead-letter queue (DLQ) in your DB. Use the CLI command `php artisan ecotone:replay-dlq` to replay them. For monitoring, track the `ecotone_messages` table’s `status` column. Set up alerts for DLQ growth to avoid backlogs.
- Does ecotone/dbal support distributed transactions (e.g., outbox pattern)?
- Yes, via the outbox pattern. Annotate your handler with `#[Outbox]` and use `OutboxMessage::publish()` to atomically commit DB changes and messages. This prevents event loss during crashes. Works seamlessly with Laravel’s transactions.
- Can I use ecotone/dbal for sagas (long-running workflows) in Laravel?
- Absolutely. Define sagas with `#[Saga]` and steps with `#[Step]`. The package stores saga state in your DB (table: `ecotone_saga_states`). For distributed systems, consider adding Redis for lock coordination to avoid deadlocks.
- What’s the performance impact of using a DB-backed message queue vs. RabbitMQ?
- DB-backed channels typically handle **1K–10K messages/sec** (vs. RabbitMQ’s 100K+). For high throughput, optimize your DB (indexes on `status`, `processed_at`), use read replicas for consumers, or partition tables by `message_id`. Benchmark with your payload size.
- How do I migrate existing Laravel Jobs to ecotone/dbal?
- Refactor your `Job` classes to use `#[CommandHandler]` attributes. Replace `dispatch()` with `bus->dispatch()`. Test incrementally—start with non-critical jobs. Use `ecotone:consume` instead of `queue:work` for processing. Migrate migrations to include Ecotone’s schema (e.g., `ecotone_messages`).
- Are there alternatives to ecotone/dbal for DB-backed messaging in Laravel?
- Yes: **Laravel’s built-in queues** (Redis/SQS), **Symfony Messenger with Doctrine transport**, or **Pulsar/NATS** for high-scale systems. Ecotone/dbal stands out by bundling *messaging, outbox, DLQ, and sagas* in one package with declarative PHP 8 attributes—ideal if you want to avoid microservices complexity.
- How do I monitor ecotone/dbal in production? What metrics should I track?
- Track these key metrics: `ecotone_messages` table growth (size/age), DLQ backlog size, saga timeout failures, and consumer lag. Use Laravel’s `queue:failed` table for failed jobs. For observability, log message processing time and integrate with tools like Prometheus for DB query metrics.