Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions PaymentService/Infrastructure/PaymentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public async Task ExecuteInTransactionAsync(Func<CancellationToken, Task> work,
{
await using var tx = await context.Database.BeginTransactionAsync(ct);
await work(ct);

// CRITICAL: SaveChangesAsync after work() is what flushes Wolverine's staged
// outbox envelopes. Wolverine's UseEntityFrameworkCoreTransactions bridge
// intercepts SaveChanges to persist the wolverine.outgoing_envelopes rows
// *in the same transaction* as the entity write. Without this call,
// PublishAsync(...) inside work() stages envelopes in the change tracker
// but they never reach the DB — entity commits, event is silently dropped.
// The intermediate UpdateAsync inside work() flushes the entity, but the
// outbox row is staged *after* that point and needs a second flush here.
// See CLAUDE.md "Performance Rules — Outbox atomicity" + Wolverine outbox docs.
await context.SaveChangesAsync(ct);

await tx.CommitAsync(ct);
}
}
Loading