[#210] Add tenant-aware event processing to the multi-tenancy demo - #4795
Conversation
1bc2cab to
27d0936
Compare
45bb8fc to
d41a607
Compare
4d8aa99 to
0524eb5
Compare
|
@smcvb Two rough edges in the Spring extension that this demo ran into. Neither is multi-tenancy related, both live in 1. A 2. A pooled streaming processor requires a The two interact badly. Declaring the handler as its own Both are reproducible through this PR's Spring Boot demo, which is where I hit them. Fix them now, open issues for them, or leave them as they are? |
75b7c33 to
b2038b7
Compare
1b39c86 to
3688bb4
Compare
b2038b7 to
f853002
Compare
ea8de01 to
fdef226
Compare
I do wonder how high a priority these are, though. If you run a normal app, you'd get a |
smcvb
left a comment
There was a problem hiding this comment.
Same concern as with the previous demo - it's a lot and goes beyond showing a user how to just enable multi-tenancy for declarative and Spring Boot. But given our time window, fine enough, and a worthy additional test suite. So, approving this PR.
Demonstrates the tenant-aware pooled streaming read side from axoniq-framework#283 (axoniq-framework#210) in the multi-tenancy example.
Stacked on #4794, so the diff here is the single commit on top of it.
What it shows
The statistics read model becomes a real projection: one ordinary pooled streaming processor consumes every tenant's events and writes each into the read model of the tenant it came from.
CourseStatisticsProjectionnames no tenant, since the framework puts the tenant of a streamed event on the processing context and resolves its@TenantScopedparameters from it. Nothing identifies the tenant inside the stored event.The demo also counts what served all three tenants, finding one processor rather than one per tenant, and shows a tenant added at runtime being picked up with no configuration change.
EnrollStudentCommandHandlernow only appends, which is what its javadoc already promised.Two design points
ReadModelUpdatesselects which one writes, andEnrollmentRecordingis the single write both use, mirroring the existingTenantProvisioningandTenantSnapshotsseams.CourseStatisticsStorecounts enrolled student identifiers instead of incrementing, andAuditLogkeys its entries. Events arrive at least once, and re-opening the stream on a tenant change can repeat one.Depends on axoniq-framework#283
Examples CI fails here until that merges and a new snapshot publishes. Verified locally against one: demo unit tests green, and
MultiTenancyDemoITgreen against a containerized Axon Server, reporting one processor andspringfield=2, shelbyville=2, ogdenville=1.