This projects shows some of the features of Eventuous:
- Event-sourced domain model using
Aggregate
andAggregateState
- Aggregate persistence using SQL ServerQL
- Read models in SQL Server
- Integration between services using messaging (RabbitMQ)
- Create a new SQL Server database
Bookings
and run the scriptCreate-Tables.sql
to create the necessary tables for the projections.
- Open the
app.http
file in Visual Studio and execute the commands to interact with the API. - You can also use SwaggerUI to interact with the API.
- Create a booking by executing the
booking/book
api. - Record a payment by executing the
booking/recordPayment
api. - Get the booking state by executing the
bookings
api. - Get the booking projection by executing the
projections/sql/bookings
api.
- This command raises an event, which gets stored in the database.
- A real-time subscription triggers a projection, which adds or updates two records in SQL Server:
- one for the booking
- one for the guest
- When this command is executed, it raises a
PaymentRecorded
event, which gets persisted to the database. - A gateway inside the Payments service subscribes to this event and publishes an integration event to RabbitMQ.
- An integration RabbitMQ subscription receives the integration event and calls the Bookings service to execute the
RecordPayment
command, so it acts as a Reactor. - When that command gets executed, it raises a
PaymentRecorded
event, which gets persisted to the database. It might also raise aBookingFullyPaid
orBookingOverpaid
events, depending on the amount. - Those new events are projected to SQL Server document in the
Bookings
collection using the read-model subscription.
graph TB
HTTP --> RecordPayment
subgraph Payments
direction LR
RecordPayment -- aggregate --> PaymentRecorded[PaymentRecorded<br>domain event]
Reactor --> PR[PaymentRecorded<br>integration event]
end
subgraph SQL Server
PaymentRecorded -- eventstore --> SQLSERVER[(SQL SERVER)]
SQLSERVER -- gateway --> Reactor
end
subgraph Broker
PR --> RabbitMQ[[RabbitmQ]]
end
subgraph Bookings
direction RL
RabbitMQ -- subscription --> IH[Integration<br>handler]
IH --> RP[RecordPayment]
RP -- aggregate --> PR1[PaymentRecorded]
PR1 -- eventstore --> SQLSERVER
SQLSERVER -- subscription --> Projections
end
subgraph SQL Server
Projections --> BC[(BookingState)]
Projections --> MB[(MyBookings)]
end