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
@@ -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()`.
@@ -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()`
@@ -60,7 +87,7 @@ using SlimMessageBus.Host.Outbox.Sql;
60
87
61
88
Consider the following example:
62
89
63
-
-`services.AddMessageBusOutboxUsingSql(...)` is used to add the [Outbox.Sql](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) plugin to the container.
90
+
-`services.AddOutboxUsingSql(...)` is used to add the [Outbox.Sql](https://www.nuget.org/packages/SlimMessageBus.Host.Outbox.Sql) plugin to the container.
64
91
-`SqlConnection` is registered in the container
65
92
66
93
```cs
@@ -112,6 +139,20 @@ using SlimMessageBus.Host.Outbox;
112
139
113
140
When applied on the (child) bus level then all consumers (or handlers) will inherit that option.
114
141
142
+
#### UsePostgreSqlTransaction
143
+
144
+
> 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)
145
+
146
+
```cs
147
+
usingSlimMessageBus.Host.Outbox.PostgreSql;
148
+
```
149
+
150
+
`.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.
151
+
152
+
When applied on the (child) bus level then all consumers (or handlers) will inherit that option.
153
+
154
+
`PostgreSqlTransaction`-s are created off the associated `NpgsqlConnection`.
155
+
115
156
#### UseSqlTransaction
116
157
117
158
> 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)
@@ -135,7 +176,7 @@ When applied on the (child) bus level then all consumers (or handlers) will inhe
135
176
- When a message is sent via a bus or producer marked with `.UseOutbox()` then such message will be inserted into the `Outbox` table.
136
177
It is important that message publish happens in the context of an transaction to ensure consistency.
137
178
138
-
- 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.
179
+
- 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.
139
180
140
181
- The transaction can be managed by the application, starting it either explicitly using `DbContext.Database.BeginTransactionAsync()` or creating a `TransactionScope()`.
0 commit comments