Add axon-event-sourcing module: Axon 5.4.2 entity, projection, replay
Event-sourced bank account on Axon Framework 5.4.2 + Spring Boot 4.1.1, with transcripts generated by tests and three reproduced JPA-store variants. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b69H5rTewUKPyhGS8r
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Open, deposit, withdraw: commands in, events stored, read model updated
|
||||
|
||||
$ POST /accounts/acc-1?owner=Asha
|
||||
HTTP 201 {"accountId":"acc-1","status":"opened"}
|
||||
$ POST /accounts/acc-1/deposit?amount=500
|
||||
HTTP 200 {"accountId":"acc-1","deposited":500}
|
||||
$ POST /accounts/acc-1/withdraw?amount=120
|
||||
HTTP 200 {"accountId":"acc-1","withdrawn":120}
|
||||
|
||||
# Stored events (aggregate_event_entry), the only thing the write side persists
|
||||
seq=0 aggregate_type=accountId com.ankurm.axondemo.domain.AccountOpened {"accountId":"acc-1","owner":"Asha"}
|
||||
seq=1 aggregate_type=accountId com.ankurm.axondemo.domain.MoneyDeposited {"accountId":"acc-1","amount":500}
|
||||
seq=2 aggregate_type=accountId com.ankurm.axondemo.domain.MoneyWithdrawn {"accountId":"acc-1","amount":120}
|
||||
|
||||
# Read model, filled by the event handlers
|
||||
$ GET /accounts/acc-1
|
||||
HTTP 200 {"accountId":"acc-1","owner":"Asha","balance":380,"eventsApplied":3}
|
||||
@@ -0,0 +1,10 @@
|
||||
# Rejected commands append no events
|
||||
|
||||
$ POST /accounts/acc-1/withdraw?amount=9999
|
||||
HTTP 409 {"error":"Insufficient funds: balance 380, requested 9999"}
|
||||
$ POST /accounts/acc-1?owner=Again
|
||||
HTTP 409 {"error":"Account already exists"}
|
||||
$ POST /accounts/nobody/deposit?amount=5
|
||||
HTTP 404 {"error":"No such account"}
|
||||
|
||||
events in the store after three rejected commands: 3 (still the 3 from the first scenario)
|
||||
@@ -0,0 +1,7 @@
|
||||
# The entity has no table: only events and read-model rows exist
|
||||
|
||||
table: account_balance
|
||||
table: aggregate_event_entry
|
||||
table: token_entry
|
||||
|
||||
no table named bank_account: BankAccount.balance exists only while a command runs
|
||||
@@ -0,0 +1,16 @@
|
||||
# Lose the read model, replay the events, get it back
|
||||
|
||||
# Simulate a lost or corrupted read model: DELETE FROM account_balance (2 rows)
|
||||
$ GET /accounts/acc-1
|
||||
HTTP 404
|
||||
events still in the store: 5
|
||||
|
||||
$ POST /admin/replay
|
||||
HTTP 200 {"status":"replay started"}
|
||||
|
||||
# After the replay
|
||||
$ GET /accounts/acc-1
|
||||
HTTP 200 {"accountId":"acc-1","owner":"Asha","balance":380,"eventsApplied":3}
|
||||
$ GET /accounts/acc-2
|
||||
HTTP 200 {"accountId":"acc-2","owner":"Ravi","balance":40,"eventsApplied":2}
|
||||
events in the store after the replay: 5 (a replay reads events, it never writes them)
|
||||
@@ -0,0 +1,4 @@
|
||||
# Broken variant: tag-key-mismatch
|
||||
|
||||
OpenAccount[accountId=v-1, owner=Asha] -> OK
|
||||
Deposit[accountId=v-1, amount=10] -> OK
|
||||
@@ -0,0 +1,4 @@
|
||||
# Broken variant: id-only-creator
|
||||
|
||||
OpenAccount[accountId=v-1, owner=Asha] -> org.axonframework.modelling.entity.EntityMissingForInstanceCommandHandlerException: Entity was missing for instance command handler for command [com.ankurm.axondemo.domain.OpenAccount#0.0.1]
|
||||
Deposit[accountId=v-1, amount=10] -> org.axonframework.modelling.entity.EntityMissingForInstanceCommandHandlerException: Entity was missing for instance command handler for command [com.ankurm.axondemo.domain.Deposit#0.0.1]
|
||||
@@ -0,0 +1,4 @@
|
||||
# Broken variant: two-tags
|
||||
|
||||
OpenAccount[accountId=v-1, owner=Asha] -> OK
|
||||
Deposit[accountId=v-1, amount=10] -> org.axonframework.eventsourcing.eventstore.TooManyTagsOnEventMessageException: An Event Storage engine in Aggregate mode does not support multiple tags per event
|
||||
Reference in New Issue
Block a user