1
- # Pandatech.MassTransit.PostgresOutbox
1
+ - [ 1. Pandatech.MassTransit.PostgresOutbox] ( #1-pandatechmasstransitpostgresoutbox )
2
+ - [ 1.1. Features] ( #11-features )
3
+ - [ 1.2. Getting Started] ( #12-getting-started )
4
+ - [ 1.3. Installation] ( #13-installation )
5
+ - [ 1.4. Configuration] ( #14-configuration )
6
+ - [ 1.5. Usage] ( #15-usage )
7
+ - [ 1.5.1. Configuration] ( #151-configuration )
8
+ - [ 1.5.2. Publishing Messages (Outbox Pattern)] ( #152-publishing-messages-outbox-pattern )
9
+ - [ 1.5.3. Consuming Messages (Inbox Pattern)] ( #153-consuming-messages-inbox-pattern )
10
+ - [ 1.6. License] ( #16-license )
11
+
12
+ # 1. Pandatech.MassTransit.PostgresOutbox
2
13
3
14
Welcome to the Pandatech MassTransit PostgreSQL Outbox Extension repository. This library is designed to enhance
4
15
MassTransit's capabilities by introducing robust support for the Outbox and Inbox patterns with a particular focus on
5
16
PostgreSQL, alongside seamless integration with multiple DbContexts in Entity Framework Core. This extension is ideal
6
17
for developers seeking to ensure reliable message delivery and processing in distributed, microservice-oriented
7
18
architectures.
8
19
9
- ## Features
20
+ ## 1.1. Features
10
21
11
22
- ** Multiple DbContext Support** : Operate within complex systems using multiple data contexts without hassle.
12
23
- ** Outbox Pattern Implementation** : Reliably handle message sending operations, ensuring no messages are lost in
@@ -17,23 +28,23 @@ architectures.
17
28
control, making your message handling processes more robust.
18
29
- ** Seamless Integration** : Designed to fit effortlessly into existing MassTransit and EF Core based projects.
19
30
20
- ## Getting Started
31
+ ## 1.2. Getting Started
21
32
22
33
To get started with the Pandatech MassTransit PostgreSQL Outbox Extension, ensure you have the following prerequisites:
23
34
24
35
- .NET Core 8 or later
25
36
- An existing MassTransit project
26
37
- PostgreSQL database
27
38
28
- ## Installation
39
+ ## 1.3. Installation
29
40
30
41
The library can be installed via NuGet Package Manager. Use the following command:
31
42
32
43
``` bash
33
44
Install-Package Pandatech.MassTransit.PostgresOutbox
34
45
```
35
46
36
- ## Configuration
47
+ ## 1.4. Configuration
37
48
38
49
Before diving into the usage, it's essential to configure the Pandatech MassTransit PostgreSQL Outbox Extension in your
39
50
application. This involves setting up your DbContexts, configuring MassTransit to use the extension, and initializing
@@ -42,47 +53,45 @@ the Outbox and Inbox features.
42
53
Stay tuned for the next sections where we'll cover the usage details, showcasing how you can leverage this powerful
43
54
extension to enhance your distributed systems.
44
55
45
- ## Usage
56
+ ## 1.5. Usage
57
+
46
58
Take into account that examples below are given for configuring both inbox and outbox patterns.
47
- If you need only one of those , consider using appropriate methods available(eg. instead of AddOutboxInboxServices use AddInboxServices and etc).
59
+ If you need only one of those , consider using appropriate methods available(eg. instead of AddOutboxInboxServices use
60
+ AddInboxServices and etc).
48
61
49
- Configuration
62
+ ### 1.5.1. Configuration
50
63
51
- Entity Configuration: Ensure your DbContext implements the IOutboxDbContext and IInboxDbContext interfaces.
52
- Configure your entities and generate migrations.
53
- Call ConfigureInboxOutboxEntities on your ModelBuilder to configure the necessary tables for inbox and outbox patterns.
64
+ ** Entity Configuration:** Ensure your ` DbContext ` implements the ` IOutboxDbContext ` and ` IInboxDbContext ` interfaces.
65
+ Configure your entities and generate migrations.
66
+ Call ` ConfigureInboxOutboxEntities ` on your ` ModelBuilder ` to configure the necessary tables for inbox and outbox patterns.
54
67
55
68
``` csharp
56
-
57
69
protected override void OnModelCreating (ModelBuilder modelBuilder )
58
70
{
59
71
modelBuilder .ConfigureInboxOutboxEntities ();
60
72
}
61
73
```
62
-
63
- And you need to call UseQueryLocks() inside AddDbContext or AddDbContextPool , this needs for enabling ForUpdate feature.
64
-
74
+ And you need to call ` UseQueryLocks() ` inside ` AddDbContext ` or ` AddDbContextPool ` , this needs for enabling ` ForUpdate `
75
+ feature.
65
76
``` csharp
66
- builder .Services .AddDbContextPool <PostgresContext >(options =>
77
+ builder .Services .AddDbContextPool <PostgresContext >(options =>
67
78
options .UseNpgsql (connectionString )
68
79
.UseQueryLocks ());
69
80
```
70
81
71
- Service Registration: Register essential services on startup, specifying the DbContext type.
82
+ ** Service Registration:** Register essential services on startup, specifying the ` DbContext ` type.
72
83
You can optionally override settings(its optional parameter).
73
84
74
85
``` csharp
75
-
76
86
services .AddOutboxInboxServices <PostgresContext >();
77
87
```
78
88
79
- Publishing Messages (Outbox Pattern)
89
+ ### 1.5.2. Publishing Messages (Outbox Pattern)
80
90
81
- To publish a message using the outbox pattern, call the AddToOutbox method on your DbContext,
82
- specifying your message. Remember to call SaveChanges() to persist the message to the database.
91
+ To publish a message using the outbox pattern, call the ` AddToOutbox ` method on your ` DbContext ` ,
92
+ specifying your message. Remember to call ` SaveChanges() ` to persist the message to the database.
83
93
84
94
``` csharp
85
-
86
95
dbContext .Orders .Add (new Order
87
96
{
88
97
Amount = 555 ,
@@ -96,10 +105,10 @@ dbContext.AddToOutbox(new OrderCreatedEvent());
96
105
dbContext .SaveChanges ();
97
106
```
98
107
99
- Consuming Messages (Inbox Pattern)
108
+ ### 1.5.3. Consuming Messages (Inbox Pattern)
100
109
101
110
To consume messages using the inbox pattern, create a consumer that inherits from
102
- InboxConsumer<TMessage, TDbContext> class, specifying the message type and DbContext type as generic arguments.
111
+ ` InboxConsumer<TMessage, TDbContext> ` class, specifying the message type and ` DbContext ` type as generic arguments.
103
112
104
113
``` csharp
105
114
@@ -120,6 +129,6 @@ public class YourConsumer : InboxConsumer<YourMessage, PostgresContext>
120
129
}
121
130
```
122
131
123
- ## License
132
+ ## 1.6. License
124
133
125
134
Pandatech.MassTransit.PostgresOutbox is licensed under the MIT License.
0 commit comments