You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/articles/outbox-pattern.md
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,14 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
54
54
55
55
`BaseDbContext` owns the `OutboxMessages``DbSet`; apply the provider-optimized mapping in `OnModelCreating` by calling your provider's extension — `ApplyNpgsqlOutbox()`, `ApplyMySqlOutbox()`, or `ApplyCosmosOutbox()` (as shown above). The agnostic `ApplyOutbox()` is available for custom providers.
56
56
57
+
Only one outbox-enabled `DbContext` is supported per host: the relay and retention background services resolve a
58
+
single `IOutboxStore`, so calling `EnableOutboxProcessing()` for a second context throws an
59
+
`InvalidOperationException` at startup instead of silently leaving the first context's messages unrelayed. The
60
+
Npgsql and MySQL stores also require your context to derive from `BaseDbContext` (or otherwise implement
61
+
`IUnitOfWork`) — without a transaction their `FOR UPDATE SKIP LOCKED` fetch would release its locks immediately,
62
+
letting concurrent relay instances double-dispatch the same messages, so `RelationalOutboxStore` throws instead of
63
+
running unprotected.
64
+
57
65
## Outbox Processing Options
58
66
59
67
| Property | Default | Description |
@@ -166,6 +174,13 @@ directly. The transaction is established by one of:
166
174
transaction and the consume filter joins it rather than nesting.
167
175
-**Anything else** — wrap the work in `IUnitOfWork.ExecuteInTransactionAsync(...)`.
168
176
177
+
Ambient `System.Transactions.TransactionScope` transactions are **not supported**: the capture gate checks for an
178
+
Entity Framework Core transaction specifically, and EF Core does not surface an ambient scope as one. Publishing
179
+
inside a `TransactionScope` with no EF Core transaction throws `NotSupportedException` rather than silently
180
+
publishing directly while the scope is still uncommitted (a ghost message on rollback) — establish the transaction
181
+
with one of the options above instead. Full ambient-scope support may be added in the future; it is deferred over
0 commit comments