Skip to content

feat(redrive): DLQ redrive tooling — safe replay (ADR-0026)#3

Merged
muhammetsafak merged 1 commit into
mainfrom
feat/redrive
Jun 19, 2026
Merged

feat(redrive): DLQ redrive tooling — safe replay (ADR-0026)#3
muhammetsafak merged 1 commit into
mainfrom
feat/redrive

Conversation

@muhammetsafak

Copy link
Copy Markdown
Member

The PHP mirror of the Go babelqueue-go Redrive (ADR-0026) — the operator tool the error-handling contract deferred ("re-driving … is an operator/tooling concern"). Adapted to PHP's publish-only Transport.

What

  • BabelQueue\Redrive\Redrive::reset(array $envelope): array — pure: strip the dead_letter block, reset attempts to 0, preserve job/trace_id/data/meta verbatim.
  • Redrive::run(RedriveIO $io, string $dlq, ?RedriveOptions $options): RedriveResult — drains the DLQ and re-publishes each (reset) message to its dead_letter.original_queue or $options->toQueue. Because the core Transport is publish-only, redrive drives a small RedriveIO (reserve / ack / publish) the caller binds to their broker.
  • Options: toQueue (sandbox replay), max, dryRun (report the plan, restore everything unchanged), select (a predicate). Drains-then-processes; acks a DLQ message only after a successful re-publish; restores undecodable bodies and on a publish failure rather than dropping them.

Tests / gate

  • tests/Redrive/RedriveTest.php — 8 tests via an in-memory RedriveIO (to-source reset+trace preserved, sandbox, dry-run, select, max, restore-on-publish-failure, undecodable restored, reset purity).
  • Full suite green: 168 tests, 570 assertions. PHPStan level 9: no errors. No new dependency; envelope frozen (GR-1).

Follow-up

The Replay-Bypass guard (a bq-replay-bypass transport header surfaced to handlers so a replay can skip external side-effects) is a documented phase two, reusing ADR-0025's out-of-band-header pattern.

🤖 Generated with Claude Code

BabelQueue\Redrive: the PHP mirror of the Go redrive reference, adapted to PHP's publish-only Transport. Redrive::reset() (pure: strip dead_letter, attempts->0, preserve job/trace_id/data/meta) + Redrive::run(RedriveIO, dlq, opts) over a small reserve/ack/publish seam — re-publishes each dead-lettered message to its dead_letter.original_queue or a sandbox toQueue. Options: toQueue, max, dryRun, select. Drains-then-processes; acks only after a successful re-publish; restores undecodable bodies and on publish failure. No new dependency; envelope frozen (GR-1). Replay-Bypass header documented as phase two.
@muhammetsafak muhammetsafak merged commit 25c428e into main Jun 19, 2026
9 checks passed
@muhammetsafak muhammetsafak deleted the feat/redrive branch June 19, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant