In exercises 12-14 you built projections from a single event stream. Now you'll combine events from multiple streams into a single read model.
A payment verification requires data from three independent checks, each producing events on its own stream:
- Payment recorded — from the payment service (amount, order reference)
- Merchant limits checked — from the merchant service (within daily limits?)
- Fraud score calculated — from the fraud detection service (risk score, acceptable?)
- Verification completed — final decision event (approved or rejected)
All events share a PaymentId that ties them to the same payment verification read model.
With the Database interface representing the sample database, implement a PaymentVerification read model and projection:
- Define the
PaymentVerificationread model properties — the test assertions tell you what shape it needs. - Create a
PaymentVerificationProjectionclass with typedHandlemethods for each event. - Register handlers in the test using
eventStore.Register.
The key difference from single-stream projections: each event arrives on a different stream ID, but they all reference the same PaymentId. Your projection must use PaymentId (not the stream ID) as the read model key.
Read more about multi-stream projections and handling events from multiple sources: