mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 22:17:38 +00:00
fix: correct typos in event-sourcing (#2442)
This commit is contained in:
1 parent
2263e248bd
commit
186b5b6ff2
8 files changed
+18
-17
No files matched your search
@@ -16,7 +16,7 @@ Instead of storing just the current state of the data in a domain, use an append
|
|||||||
## Applicability
|
## Applicability
|
||||||
Use the Event Sourcing pattern when
|
Use the Event Sourcing pattern when
|
||||||
|
|
||||||
* You need very high performance on persisting your application state even your application state have a complex relational data structure
|
* You need very high performance on persisting your application state even your application state has a complex relational data structure
|
||||||
* You need log of changes of your application state and ability to restore a state of any moment in time.
|
* You need log of changes of your application state and ability to restore a state of any moment in time.
|
||||||
* You need to debug production problems by replaying the past events.
|
* You need to debug production problems by replaying the past events.
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import java.util.Date;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Sourcing : Instead of storing just the current state of the data in a domain, use an
|
* Event Sourcing: Instead of storing just the current state of the data in a domain, use an
|
||||||
* append-only store to record the full series of actions taken on that data. The store acts as the
|
* append-only store to record the full series of actions taken on that data. The store acts as the
|
||||||
* system of record and can be used to materialize the domain objects. This can simplify tasks in
|
* system of record and can be used to materialize the domain objects. This can simplify tasks in
|
||||||
* complex domains, by avoiding the need to synchronize the data model and the business domain,
|
* complex domains, by avoiding the need to synchronize the data model and the business domain,
|
||||||
@@ -42,11 +42,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
* transactional data, and maintain full audit trails and history that can enable compensating
|
* transactional data, and maintain full audit trails and history that can enable compensating
|
||||||
* actions.
|
* actions.
|
||||||
*
|
*
|
||||||
* <p>This App class is an example usage of Event Sourcing pattern. As an example, two bank account
|
* <p>This App class is an example usage of an Event Sourcing pattern. As an example, two bank accounts
|
||||||
* is created, then some money deposit and transfer actions are taken so a new state of accounts is
|
* are created, then some money deposit and transfer actions are taken, so a new state of accounts is
|
||||||
* created. At that point, state is cleared in order to represent a system shot down. After the shot
|
* created. At that point, state is cleared in order to represent a system shut-down. After the shut-down,
|
||||||
* down, system state is recovered by re-creating the past events from event journal. Then state is
|
* system state is recovered by re-creating the past events from event journals. Then state is
|
||||||
* printed so a user can view the last state is same with the state before system shot down.
|
* printed so a user can view the last state is same with the state before a system shut-down.
|
||||||
*
|
*
|
||||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class Account {
|
|||||||
/**
|
/**
|
||||||
* Handles the AccountCreateEvent.
|
* Handles the AccountCreateEvent.
|
||||||
*
|
*
|
||||||
* @param accountCreateEvent the account create event
|
* @param accountCreateEvent the account created event
|
||||||
*/
|
*/
|
||||||
public void handleEvent(AccountCreateEvent accountCreateEvent) {
|
public void handleEvent(AccountCreateEvent accountCreateEvent) {
|
||||||
AccountAggregate.putAccount(this);
|
AccountAggregate.putAccount(this);
|
||||||
|
|||||||
+4
-3
@@ -29,8 +29,9 @@ import com.iluwatar.event.sourcing.state.AccountAggregate;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that implements account create event. Holds the necessary info for an account
|
* This is the class that implements account created event.
|
||||||
* create event. Implements the process function that finds the event related domain objects and
|
* Holds the necessary info for an account created event.
|
||||||
|
* Implements the process function that finds the event-related domain objects and
|
||||||
* calls the related domain object's handle event functions
|
* calls the related domain object's handle event functions
|
||||||
*
|
*
|
||||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||||
@@ -42,7 +43,7 @@ public class AccountCreateEvent extends DomainEvent {
|
|||||||
private final String owner;
|
private final String owner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Account create event.
|
* Instantiates a new Account created event.
|
||||||
*
|
*
|
||||||
* @param sequenceId the sequence id
|
* @param sequenceId the sequence id
|
||||||
* @param createdTime the created time
|
* @param createdTime the created time
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that implements money deposit event. Holds the necessary info for a money
|
* This is the class that implements money deposit event. Holds the necessary info for a money
|
||||||
* deposit event. Implements the process function that finds the event related domain objects and
|
* deposit event. Implements the process function that finds the event-related domain objects and
|
||||||
* calls the related domain object's handle event functions
|
* calls the related domain object's handle event functions
|
||||||
*
|
*
|
||||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the class that implements money transfer event. Holds the necessary info for a money
|
* This is the class that implements money transfer event. Holds the necessary info for a money
|
||||||
* transfer event. Implements the process function that finds the event related domain objects and
|
* transfer event. Implements the process function that finds the event-related domain objects and
|
||||||
* calls the related domain object's handle event functions
|
* calls the related domain object's handle event functions
|
||||||
*
|
*
|
||||||
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
* <p>Created by Serdar Hamzaogullari on 06.08.2017.
|
||||||
|
|||||||
+2
-2
@@ -91,7 +91,7 @@ public class JsonFileJournal {
|
|||||||
} else if (domainEvent instanceof MoneyTransferEvent) {
|
} else if (domainEvent instanceof MoneyTransferEvent) {
|
||||||
jsonElement = gson.toJsonTree(domainEvent, MoneyTransferEvent.class);
|
jsonElement = gson.toJsonTree(domainEvent, MoneyTransferEvent.class);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Journal Event not recegnized");
|
throw new RuntimeException("Journal Event not recognized");
|
||||||
}
|
}
|
||||||
|
|
||||||
try (var output = new BufferedWriter(
|
try (var output = new BufferedWriter(
|
||||||
@@ -113,7 +113,7 @@ public class JsonFileJournal {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read next domain event.
|
* Read the next domain event.
|
||||||
*
|
*
|
||||||
* @return the domain event
|
* @return the domain event
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intergartion Test for Event Sourcing state recovery
|
* Integration Test for Event-Sourcing state recovery
|
||||||
* <p>
|
* <p>
|
||||||
* Created by Serdar Hamzaogullari on 19.08.2017.
|
* Created by Serdar Hamzaogullari on 19.08.2017.
|
||||||
*/
|
*/
|
||||||
@@ -95,4 +95,4 @@ class IntegrationTest {
|
|||||||
assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
|
assertEquals(accountOfJonBeforeShotDown.getMoney(), accountOfJonAfterShotDown.getMoney());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user