# `PhoenixMicro.Outbox.Relay`
[🔗](https://github.com/iamkanishka/phoenix_micro/blob/v1.0.0/lib/phoenix_micro/outbox.ex#L230)

GenServer that polls the `outbox_messages` table and relays undelivered
messages to the configured transport.

Requires `ecto_sql` in your application's deps:

    {:ecto_sql, "~> 3.11"}

## Behaviour

Every `:poll_interval_ms` (default 1000ms) the relay:

1. Selects up to `:batch_size` rows where `relayed_at IS NULL`
   and `attempt <= max_attempts`, ordered by `inserted_at ASC`.
2. For each row, calls `PhoenixMicro.publish_sync/3`.
3. On success: marks `relayed_at = now()`.
4. On failure: increments `attempt`, sets `last_error`.
   Once `attempt > max_attempts`, sets `failed_at = now()` and gives up.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
