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: README.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,8 @@ The configuration can be [modularized](docs/intro.md#modularization-of-configura
167
167
|`.Host.AspNetCore`| Integration for ASP.NET Core |[](https://www.nuget.org/packages/SlimMessageBus.Host.AspNetCore)|
168
168
|`.Host.Interceptor`| Core interface for interceptors |[](https://www.nuget.org/packages/SlimMessageBus.Host.Interceptor)|
169
169
|`.Host.FluentValidation`| Validation for messages based on [FluentValidation](https://www.nuget.org/packages/FluentValidation)|[](https://www.nuget.org/packages/SlimMessageBus.Host.FluentValidation)|
170
+
|`.Host.Outbox.PostgreSql`| Transactional Outbox using PostgreSQL |[](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql)|
171
+
|`.Host.Outbox.PostgreSql.DbContext`| Transactional Outbox using PostgreSQL with EF DataContext integration |[](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql.DbContext)|
170
172
|`.Host.Outbox.Sql`| Transactional Outbox using MSSQL |[](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql)|
171
173
|`.Host.Outbox.Sql.DbContext`| Transactional Outbox using MSSQL with EF DataContext integration |[](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext)|
172
174
|`.Host.AsyncApi`|[AsyncAPI](https://www.asyncapi.com/) specification generation via [Saunter](https://github.com/tehmantra/saunter)|[](https://www.nuget.org/packages/SlimMessageBus.Host.AsyncApi)|
@@ -18,16 +23,29 @@ Please read the [Introduction](intro.md) before reading this provider documentat
18
23
## Introduction
19
24
20
25
The [`Host.Outbox`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox) introduces [Transactional Outbox](https://microservices.io/patterns/data/transactional-outbox.html) pattern to the SlimMessageBus.
21
-
It comes in two flavors:
22
26
27
+
PostgreSQL
28
+
-[`Host.Outbox.PostgreSql`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql) as integration with the [Npgsql](https://www.npgsql.org/) client
29
+
-[`Host.Outbox.PostgreSql.DbContext`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql.DbContext) as integration with Entity Framework Core using Npgsql
30
+
31
+
SQL server
23
32
-[`Host.Outbox.Sql`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) as integration with the System.Data.Sql client (MSSQL)
24
-
-[`Host.Outbox.Sql.DbContext`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext) as integration with Entity Framework Core
33
+
-[`Host.Outbox.Sql.DbContext`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext) as integration with Entity Framework Core using System.Data.Sql
25
34
26
35
Outbox plugin can work in combination with any transport provider.
@@ -40,7 +58,7 @@ Consider the following example (from [Samples](../src/Samples/Sample.OutboxWebAp
40
58
-`services.AddOutboxUsingDbContext<CustomerContext>(...)` is used to add the [Outbox.DbContext](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext) plugin to the container.
41
59
-`CustomerContext` is the application specific Entity Framework `DbContext`.
42
60
-`CustomerCreatedEvent` is produced on the `AzureSB` child bus, the bus will deliver these events via outbox - see `.UseOutbox()`
43
-
-`CreateCustomerCommand` is consumed on the `Memory` child bus, each command is wrapped in an SQL transaction - see `UseSqlTransaction()`
61
+
-`CreateCustomerCommand` is consumed on the `Memory` child bus, each command is wrapped in an SQL transaction - see `UsePostgreSqlTransaction()` / `UseSqlTransaction()`
//.UseTransactionScope(messageTypeFilter: t => t.Name.EndsWith("Command")) // Consumers/Handlers will be wrapped in a TransactionScope
75
+
//.UseSqlTransaction(messageTypeFilter: t => t.Name.EndsWith("Command")); // Consumers/Handlers will be wrapped in a SqlTransaction ending with Command
76
+
77
+
switch (dbProvider)
78
+
{
79
+
caseDbProvider.SqlServer:
80
+
mbb.UseSqlTransaction(messageTypeFilter: t=>t.Name.EndsWith("Command")); // Consumers/Handlers will be wrapped in a SqlTransaction ending with Command
81
+
break;
82
+
83
+
caseDbProvider.PostgreSql:
84
+
mbb.UsePostgreSqlTransaction(messageTypeFilter: t=>t.Name.EndsWith("Command")); // Consumers/Handlers will be wrapped in a SqlTransaction ending with Command
// All outgoing messages from this bus will go out via an outbox
84
-
.UseOutbox(/* messageTypeFilter: t => t.Name.EndsWith("Command") */); //Additionaly, can apply filter do determine messages that should go out via outbox
113
+
.UseOutbox(/* messageTypeFilter: t => t.Name.EndsWith("Command") */); //Additionally, can apply filter do determine messages that should go out via outbox
@@ -129,7 +187,7 @@ using SlimMessageBus.Host.Outbox.Sql;
129
187
130
188
Consider the following example:
131
189
132
-
-`services.AddMessageBusOutboxUsingSql(...)` is used to add the [Outbox.Sql](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) plugin to the container.
190
+
-`services.AddOutboxUsingSql(...)` is used to add the [Outbox.Sql](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) plugin to the container.
133
191
-`SqlConnection` is registered in the container
134
192
135
193
```cs
@@ -181,6 +239,20 @@ using SlimMessageBus.Host.Outbox;
181
239
182
240
When applied on the (child) bus level then all consumers (or handlers) will inherit that option.
183
241
242
+
#### UsePostgreSqlTransaction
243
+
244
+
> Required: [`SlimMessageBus.Host.Outbox.PostgreSql`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql) or [`SlimMessageBus.Host.Outbox.PostgreSql.DbContext`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.PostgreSql.DbContext)
245
+
246
+
```cs
247
+
usingSlimMessageBus.Host.Outbox.PostgreSql;
248
+
```
249
+
250
+
`.UsePostgreSqlTransaction()` can be used on consumers (or handlers) declaration to force the consumer to start a `PostgreSqlTransaction` prior the message `OnHandle` and to complete that transaction after it. Any exception raised by the consumer would cause the transaction to be rolled back.
251
+
252
+
When applied on the (child) bus level then all consumers (or handlers) will inherit that option.
253
+
254
+
`PostgreSqlTransaction`-s are created off the associated `NpgsqlConnection`.
255
+
184
256
#### UseSqlTransaction
185
257
186
258
> Required: [`SlimMessageBus.Host.Outbox.Sql`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) or [`SlimMessageBus.Host.Outbox.Sql.DbContext`](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql.DbContext)
@@ -204,7 +276,7 @@ When applied on the (child) bus level then all consumers (or handlers) will inhe
204
276
- When a message is sent via a bus or producer marked with `.UseOutbox()` then such message will be inserted into the `Outbox` table.
205
277
It is important that message publish happens in the context of an transaction to ensure consistency.
206
278
207
-
- When the message publication happens in the context of a consumer (or handler) of another message, the `.UseTransactionScope()`, `.UseSqlTransaction()` can be used to start a transaction.
279
+
- When the message publication happens in the context of a consumer (or handler) of another message, the `.UseTransactionScope()`, `.UseSqlTransaction()`or `.UseSqlTransaction()`can be used to start a transaction.
208
280
209
281
- The transaction can be managed by the application, starting it either explicitly using `DbContext.Database.BeginTransactionAsync()` or creating a `TransactionScope()`.
0 commit comments