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
When the customer places an order the following process starts up (the happy path):
78
78
79
-
1. Shipping service prepares a new delivery.
80
-
1. Sales service creates a new order and publishes the `OrderPlaced` event.
81
-
1. Shipping service accepts the delivery.
82
-
1. Billing service collects payment for the order and publishes the `PaymentCollected` event.
83
-
1. Warehouse service fetches goods from the stock and publishes the `GoodsFetched` event.
84
-
1. Shipping service dispatches the delivery and publishes the `DeliveryDispatched` event.
85
-
1. Warehouse service updates the stock.
79
+
1. Shipping prepares a new delivery.
80
+
1. Sales creates a new order and publishes the `OrderPlaced` event.
81
+
1. Shipping accepts the delivery.
82
+
1. Billing collects payment for the order and publishes the `PaymentCollected` event.
83
+
1. Warehouse fetches goods from the stock and publishes the `GoodsFetched` event.
84
+
1. Shipping dispatches the delivery and publishes the `DeliveryDispatched` event.
85
+
1. Warehouse updates the stock.
86
86
87
87
There is only the basic "happy path" workflow implemented with a big room for improvement, for example when Shipping doesn't get bot Events within a time period, the delivery process should be cancelled etc..
88
88
@@ -96,7 +96,7 @@ The actual dependencies come only from Listeners which fulfill the role of the A
96
96
97
97
Events contain no Domain Objects.
98
98
99
-
For communication across Services an Event Publisher abstraction is used, located in the package `..ecommerce.common`. The interface is an Output Port (in the Hexagonal Architecture) and as a cross-cutting concern is its implementation injected by the Application.
99
+
For communication across Services an Event Publisher abstraction is used, located in the package `..ecommerce.common.events`. The interface is an Output Port (in the Hexagonal Architecture) and as a cross-cutting concern is its implementation injected by the Application.
100
100
101
101
## Architectural Overview
102
102
@@ -146,7 +146,7 @@ As shown in the previous section, the code is structured by the domain together
146
146
147
147
Such a packaging style is the first step for a further modularization.
148
148
149
-
The semantic of a package is following: `company.product.domain.aggregate.impl`, where `aggregate` and `impl` are optional. Full example: `com.ttulka.ecommerce.billing.payment.jdbc`.
149
+
The semantic of a package is following: `company.product.domain.service.[entity|impl]`, where `entity` and `impl` are optional. Full example: `com.ttulka.ecommerce.billing.payment.jdbc`.
150
150
151
151
### Assembling
152
152
@@ -155,63 +155,67 @@ To show that the Monolith architectural pattern is not equal to the Big Ball Of
155
155
The services can be further cut into separate modules (eg. Maven artifacts) by feature:
156
156
```
157
157
com.ttulka.ecommerce:ecommerce-application
158
-
com.ttulka.ecommerce:billing-service
159
-
com.ttulka.ecommerce:sales-service
160
-
com.ttulka.ecommerce:shipping-service
161
-
com.ttulka.ecommerce:warehouse-service
158
+
com.ttulka.ecommerce.sales:catalog-service
159
+
com.ttulka.ecommerce.sales:cart-service
160
+
com.ttulka.ecommerce.sales:order-service
161
+
com.ttulka.ecommerce.billing:payment-service
162
+
com.ttulka.ecommerce.shipping:delivery-service
163
+
com.ttulka.ecommerce.warehouse:warehouse-service
162
164
```
163
165
164
166
Or by [component](https://blog.ttulka.com/package-by-component-with-clean-modules-in-java):
165
167
```
166
-
com.ttulka.ecommerce:billing-domain
167
-
com.ttulka.ecommerce:billing-jdbc
168
-
com.ttulka.ecommerce:billing-rest
169
-
com.ttulka.ecommerce:billing-events
170
-
com.ttulka.ecommerce:billing-listeners
168
+
com.ttulka.ecommerce.billing:payment-domain
169
+
com.ttulka.ecommerce.billing:payment-jdbc
170
+
com.ttulka.ecommerce.billing:payment-rest
171
+
com.ttulka.ecommerce.billing:payment-events
172
+
com.ttulka.ecommerce.billing:payment-listeners
171
173
```
172
174
173
175
In detail:
174
176
```
175
-
com.ttulka.ecommerce:billing-domain
177
+
com.ttulka.ecommerce.billing:payment-domain
176
178
..billing
177
179
payment
178
180
Payment
179
181
PaymentId
180
-
ReferenceId
181
-
Money
182
-
CollectPayment
183
-
FindPayments
184
-
com.ttulka.ecommerce:billing-jdbc
182
+
CollectPayment
183
+
FindPayments
184
+
com.ttulka.ecommerce.billing:payment-jdbc
185
185
..billing.payment.jdbc
186
186
PaymentJdbc
187
-
PaymentsJdbc
188
-
com.ttulka.ecommerce:billing-rest
189
-
..billing.rest
187
+
CollectPaymentJdbc
188
+
FindPaymentsJdbc
189
+
com.ttulka.ecommerce.billing:payment-rest
190
+
..billing.payment.rest
190
191
PaymentController
191
-
com.ttulka.ecommerce:billing-events
192
-
..billing
192
+
com.ttulka.ecommerce.billing:payment-events
193
+
..billing.payment
193
194
PaymentCollected
194
-
com.ttulka.ecommerce:billing-listeners
195
-
..billing.listeners
196
-
OrderPlacedListener
195
+
com.ttulka.ecommerce.billing:payment-listeners
196
+
..billing.payment.listeners
197
+
OrderPlacedListener
197
198
```
198
199
199
200
Which can be brought together with a Spring Boot Starter, containing only Configuration classes and dependencies on other modules:
Note: Events are actually part of the domain, that's why they are in the package `..ecommerce.billing` and not in `..ecommerce.billing.events`. They are in a separate module to break the build cyclic dependencies: a dependent module (Listener) needs to know only Events and not the entire Domain.
212
+
Note: Events are actually part of the domain, that's why they are in the package `..ecommerce.billing.payment` and not in `..ecommerce.billing.payment.events`. They are in a separate module to break the build cyclic dependencies: a dependent module (Listener) needs to know only Events and not the entire Domain.
212
213
213
214
### Anatomy of a Service
214
215
216
+
**[Service](http://udidahan.com/2010/11/15/the-known-unknowns-of-soa/)** is the technical authority for a specific business capability.
217
+
- Single domain can contain multiple services (for example, Sales domain contains Catalog, Cart and Order services).
218
+
215
219
**Application** is a deployment unit. A monolithic Application can have more Services.
0 commit comments