|
1 |
| -# Bookings Sample Application |
| 1 | +# Bookings sample application - Postgres |
2 | 2 |
|
3 |
| -This projects shows some of the features of Eventuous |
4 |
| - |
5 |
| -//TODO |
6 |
| -Describe features used |
| 3 | +This projects shows some of the features of Eventuous: |
| 4 | + * Event-sourced domain model using `Aggregate` and `AggregateState` |
| 5 | + * Aggregate persistence using PostgreSQL |
| 6 | + * Read models in MongoDB |
| 7 | + * Integration between services using messaging (RabbitMQ) |
7 | 8 |
|
8 | 9 | ## Usage
|
9 | 10 |
|
| 11 | +Start the infrastructure using Docker Compose from the repository root: |
| 12 | + |
| 13 | +```bash |
| 14 | +docker compose up |
| 15 | +``` |
| 16 | + |
10 | 17 | Run both `Bookings` and `Bookings.Payments` projects and then open `http://localhost:5051/swagger/index.html` and `http://localhost:5000/swagger/index.html` respectively.
|
11 |
| -Here you can use SwaggerUI to initiate commands and queries that will result in events being raised. |
| 18 | +Here you can use SwaggerUI to initiate commands that will result in events being raised. |
12 | 19 |
|
13 | 20 | ### Example commands
|
14 | 21 |
|
15 | 22 | Bookings -> BookRoom (`/bookings/book`)
|
16 | 23 |
|
17 |
| -This command raises and event which is stored in the database but also in Mongo via a registered projection |
| 24 | +This command raises an event, which gets stored in the database. |
| 25 | +A real-time subscription triggers a projection, which adds or updates two documents in MongoDB: one for the booking and one for the guest. |
18 | 26 |
|
19 | 27 | Bookings.Payments -> RecordPayment (`/recordPayment`)
|
20 | 28 |
|
21 |
| -This command raises multiple events which is stored in the database but also puts a message in RabbitMQ which is transformed from a domain event into an integration event. Upon the integration event being handled logic and other domain events are triggered resulting |
22 |
| -in more database entries and Mongo projection data being stored. |
| 29 | +When this command is executed, it raises a `PaymentRecorded` event, which gets persisted to the database. |
| 30 | +A gateway inside the Payments service subscribes to this event and publishes an integration event to RabbitMQ. |
| 31 | +An integration RabbitMQ subscription receives the integration event and calls the Bookings service to execute the `RecordPayment` command, so it acts as a Reactor. |
| 32 | +When that command gets executed, it raises a `PaymentRecorded` event, which gets persisted to the database. It might also raise a `BookingFullyPaid` or `BookingOverpaid` events, depending on the amount. |
| 33 | +Those new events are projected to MongoDB document in the `Bookings` collection using the read-model subscription. |
23 | 34 |
|
24 | 35 | Bookings.Payments -> `CommandService:RecordPayment` -> `PaymentRecorded` -> `IntegrationSubscription` -> `BookingPaymentRecorded` -> Bookings -> RabbitMQSubscription -> `PaymentsIntegrationHandler` -> `BookingsCommandService:OnExisting<RecordPayment>` -> `V1.PaymentRecorded` -> `BookingState:On<V1.PaymentRecorded>`-> `V1.BookingFullyPaid` -> `BookingStateProjection:On<V1.PaymentRecorded>` -> `BookingStateProjection:On<V1.BookingFullyPaid>`
|
0 commit comments