|
| 1 | +<div class="highlight"><pre><span></span><span class="c">/**</span> |
| 2 | +<span class="c"> * A flow inspired by the Lakeside Mutual project (https://github.com/Microservice-API-Patterns/LakesideMutual).</span> |
| 3 | +<span class="c"> * Find the original process visualization here:</span> |
| 4 | +<span class="c"> * https://github.com/Microservice-API-Patterns/LakesideMutual/blob/master/policy-management-backend/src/main/java/com/lakesidemutual/policymanagement/domain/insurancequoterequest/RequestStatus.java</span> |
| 5 | +<span class="c"> **/</span> |
| 6 | +<span class="k">BoundedContext</span> InsuranceQuotes { |
| 7 | + <span class="k">Application</span> { |
| 8 | + <span class="k">Flow</span> QuoteRequestFlow { |
| 9 | + <span class="k">operation</span> submitRequest <span class="k">delegates</span> <span class="k">to</span> QuoteRequest[-<span class="k">></span> SUBMITTED] <span class="k">emits</span> <span class="k">event</span> RequestSubmitted |
| 10 | + <span class="k">event</span> RequestSubmitted + RequestSubmitted <span class="k">triggers</span> <span class="k">operation</span> checkRequest |
| 11 | + <span class="k">operation</span> checkRequest <span class="k">delegates</span> <span class="k">to</span> QuoteRequest[SUBMITTED -> RECEIVED <span class="k">X</span> REJECTED] <span class="k">emits</span> <span class="k">event</span> QuoteReceived <span class="k">X</span> RequestRejected |
| 12 | + <span class="k">event</span> QuoteReceived <span class="k">triggers</span> <span class="k">operation</span> receiveAndCheckQuote |
| 13 | + <span class="k">operation</span> receiveAndCheckQuote <span class="k">delegates</span> <span class="k">to</span> QuoteRequest[RECEIVED -> REJECTED <span class="k">X</span> ACCEPTED <span class="k">X</span> EXPIRED] <span class="k">emits</span> <span class="k">event</span> QuoteRejected <span class="k">X</span> QuoteAccepted <span class="k">X</span> QuoteExpired |
| 14 | + <span class="k">event</span> QuoteAccepted <span class="k">triggers</span> <span class="k">operation</span> accept |
| 15 | + <span class="k">operation</span> accept <span class="k">delegates</span> <span class="k">to</span> QuoteRequest[ACCEPTED -> POLICY_CREATED <span class="k">X</span> EXPIRED] <span class="k">emits</span> <span class="k">event</span> PolicyCreated <span class="k">X</span> QuoteExpired |
| 16 | + } |
| 17 | + } |
| 18 | + <span class="k">Aggregate</span> QuoteRequest { |
| 19 | + <span class="k">Entity</span> Request { |
| 20 | + <span class="k">aggregateRoot</span> |
| 21 | + } |
| 22 | + <span class="k">DomainEvent</span> RequestSubmitted |
| 23 | + <span class="k">DomainEvent</span> QuoteReceived |
| 24 | + <span class="k">DomainEvent</span> RequestRejected |
| 25 | + <span class="k">DomainEvent</span> QuoteRejected |
| 26 | + <span class="k">DomainEvent</span> QuoteAccepted |
| 27 | + <span class="k">DomainEvent</span> QuoteExpired |
| 28 | + <span class="k">DomainEvent</span> PolicyCreated |
| 29 | + <span class="k">Service</span> QuoteRequestService { |
| 30 | + <span class="k">void</span> submitRequest(@Request request); |
| 31 | + <span class="k">void</span> checkRequest(@Request request); |
| 32 | + <span class="k">void</span> receiveAndCheckQuote(@Request request); |
| 33 | + <span class="k">void</span> reject(@Request request); |
| 34 | + <span class="k">void</span> accept(@Request request); |
| 35 | + } |
| 36 | + <span class="k">enum</span> RequestState { |
| 37 | + <span class="k">aggregateLifecycle</span> |
| 38 | + SUBMITTED, RECEIVED, REJECTED, ACCEPTED, EXPIRED, POLICY_CREATED |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | +</pre></div> |
0 commit comments