@@ -4,8 +4,105 @@ sidebar_position: 2
44
55# Getting Started
66
7- Let's discover ** TransactionalBox in less than 5 minutes** .
7+ Let's discover ** TransactionalBox in less than 5 minutes** .
8+ Don't worry about the number of packages and if you don't understand something. I will try to introduce you step by step to the transactional box.
89
9- ## Installation
10+ ## Configuration
11+ ### Install packages
12+ ``` csharp
13+ dotnet add package TransactionalBox .Outbox .Storage .InMemory
14+ dotnet add package TransactionalBox .OutboxWorker .Storage .InMemory
15+ dotnet add package TransactionalBox .OutboxWorker .Transport .InMemory
16+ dotnet add package TransactionalBox .InboxWorker .Transport .InMemory
17+ dotnet add package TransactionalBox .InboxWorker .Storage .InMemory
18+ dotnet add package TransactionalBox .Inbox .Storage .InMemory
19+ ```
20+ ### Register
21+ ``` csharp
22+ using TransactionalBox ;
23+ using TransactionalBox .Outbox ;
24+ using TransactionalBox .Outbox .Storage .InMemory ;
25+ using TransactionalBox .OutboxWorker ;
26+ using TransactionalBox .OutboxWorker .Storage .InMemory ;
27+ using TransactionalBox .OutboxWorker .Transport .InMemory ;
28+ using TransactionalBox .InboxWorker ;
29+ using TransactionalBox .InboxWorker .Transport .InMemory ;
30+ using TransactionalBox .InboxWorker .Storage .InMemory ;
31+ using TransactionalBox .Inbox ;
32+ using TransactionalBox .Inbox .Storage .InMemory ;
33+ ```
1034
11- TODO Examples
35+ ``` csharp
36+ builder .Services .AddTransactionalBox (x =>
37+ {
38+ x .AddOutbox (storage => storage .UseInMemory ())
39+ .WithWorker (
40+ storage => storage .UseInMemory (),
41+ transport => transport .UseInMemory ());
42+
43+ x .AddInbox (storage => storage .UseInMemory ())
44+ .WithWorker (
45+ storage => storage .UseInMemory (),
46+ transport => transport .UseInMemory ());
47+ },
48+ settings => settings .ServiceId = " ServiceName" );
49+ ```
50+ ## Usage
51+ ### Outbox
52+ #### Declare outbox message
53+ ``` csharp
54+ public sealed class ExampleMessage : IOutboxMessage
55+ {
56+ public string Name { get ; init ; }
57+
58+ public int Age { get ; init ; }
59+ }
60+ ```
61+ #### Add message to outbox (to send)
62+
63+ ``` csharp
64+ public sealed class AddMessageToOutbox
65+ {
66+ private readonly IOutbox _outbox ;
67+
68+ public AddMessageToOutbox (IOutbox outbox )
69+ {
70+ _outbox = outbox ;
71+ }
72+
73+ public async Task Example ()
74+ {
75+ var message = new ExampleMessage ()
76+ {
77+ Name = " Name" ,
78+ Age = 25 ,
79+ };
80+
81+ await _outbox .Add (message , envelope => envelope .Receiver = " ServiceName" );
82+ }
83+ }
84+ ```
85+
86+ ### Inbox
87+ #### Declare inbox message
88+ ``` csharp
89+ public sealed class ExampleMessage : IInboxMessage
90+ {
91+ public string Name { get ; init ; }
92+
93+ public int Age { get ; init ; }
94+ }
95+ ```
96+ #### Handle message
97+
98+ ``` csharp
99+ internal sealed class ExampleMessageHandler : IInboxMessageHandler <ExampleMessage >
100+ {
101+ public async Task Handle (ExampleMessage message , IExecutionContext executionContext )
102+ {
103+ // Your Logic
104+ }
105+ }
106+ ```
107+ ## Summary
108+ Follow the workflow of your code with breakpoints. Enjoy learning :stuck_out_tongue_winking_eye : .
0 commit comments