Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
344 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/exploringaxon/replay/AccountCreditedReplayEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
package exploringaxon.replay; | |||
|
|||
import exploringaxon.api.event.AccountCreditedEvent; | |||
import exploringaxon.api.event.AccountDebitedEvent; | |||
import org.axonframework.eventhandling.annotation.EventHandler; | |||
import org.axonframework.eventhandling.replay.ReplayAware; | |||
import org.springframework.stereotype.Component; | |||
|
|||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
|
|||
@Component | |||
public class AccountCreditedReplayEventHandler implements ReplayAware { | |||
|
|||
List<String> audit = new ArrayList<>(); | |||
|
|||
@EventHandler | |||
public void handle(AccountCreditedEvent event) { | |||
String auditMsg = String.format("%s credited to account with account no {%s} on %s", | |||
event.getAmountCredited(), event.getAccountNo(), formatTimestampToString(event.getTimeStamp())); | |||
audit.add(auditMsg); | |||
} | |||
|
|||
@EventHandler | |||
public void handle(AccountDebitedEvent event) { | |||
String auditMsg = String.format("%s debited from account with account no {%s} on %s", | |||
event.getAmountDebited(), event.getAccountNo(), formatTimestampToString(event.getTimeStamp())); | |||
audit.add(auditMsg); | |||
} | |||
|
|||
public List<String> getAudit() { | |||
return audit; | |||
} | |||
|
|||
@Override | |||
public void beforeReplay() { | |||
audit.clear(); | |||
} | |||
|
|||
@Override | |||
public void afterReplay() { | |||
} | |||
|
|||
@Override | |||
public void onReplayFailed(Throwable cause) {} | |||
|
|||
private String formatTimestampToString(long timestamp) { | |||
return new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(timestamp * 1000); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
CREATE TABLE domainevententry | |||
( | |||
aggregateidentifier VARCHAR(255) NOT NULL, | |||
sequencenumber BIGINT NOT NULL, | |||
type VARCHAR(255) NOT NULL, | |||
eventidentifier VARCHAR(255) NOT NULL, | |||
metadata BYTEA, | |||
payload BYTEA, | |||
payloadrevision VARCHAR(255), | |||
payloadtype VARCHAR(255) NOT NULL, | |||
timestamp VARCHAR(255) NOT NULL, | |||
CONSTRAINT newdomainevententry_pkey PRIMARY KEY (aggregateidentifier, sequencenumber, type) | |||
); | |||
|
|||
|
|||
CREATE TABLE snapshotevententry | |||
( | |||
aggregateidentifier VARCHAR(255) NOT NULL, | |||
sequencenumber BIGINT NOT NULL, | |||
type VARCHAR(255) NOT NULL, | |||
eventidentifier VARCHAR(255) NOT NULL, | |||
payloadrevision VARCHAR(255), | |||
payloadtype VARCHAR(255) NOT NULL, | |||
timestamp VARCHAR(255) NOT NULL, | |||
metadata BYTEA, | |||
payload BYTEA NOT NULL, | |||
CONSTRAINT snapshotevententry_pkey1 PRIMARY KEY (aggregateidentifier, sequencenumber, type) | |||
); |
Oops, something went wrong.