Hi,
We are developing a ES based system and this is our first one. We are developing our own event store using
https://github.com/gregoryyoung/m-r/ as reference. We are using Cosmos DB as event store's persistent storage, partition key of Cosmos DB as stream id and azure function which listen to Cosmos DB change-feed and publish the events to Service Bus topic. The query service listen to events from the topic's subscription and populate the read model.
Now we have a User aggregate root. when a user create a registration request (UserRegistrationRequested event) we need a separate service that will perform some external validation, for example, validate mobile number and email address. My initial though was the Validation service will listen to UserRegistrationRequested event from ServiceBus (The same topic/exchange we are using for generating read model) and publish UserMobileNumberValidated and UserEmailAddressValidated event. Which will be then picked up by the Registration service's event handler and call the user.ValidateMobileNumber() and user.ValidateEmailAddress() to create aggregate specific event and store them.
But then I am loosing the capability to regenerate read model by replaying all events from the beginning in the topic/exchange. Because I don't want to trigger all those validation process.
Also another issue, when the UserActivated event happens I want to send email to the user's email address letting the user know you can now login. But the payload of UserActivated event does not have email address (aggregate Id only). So the Email service can't just listen to the UserActivated event and send email!
So my current thought is, okay I need use two different kind of event, The event store event (we currently calling it DomainEvent which is still a big question to me, should we simply call it Event or something else?) and Integration Event. If we do that, from where I should publish the integration events?
We can only perform transaction in single partition insert in the same container (collection). So we can not write into two different container, event store and integration event container (outbox pattern) at the same transaction. So we can not ensure integration events get published no matter what.
In my current state I am feeling I am stuck and can't figure out what to do. Can anyone please confirm if I am on the right track or not and help me figure out how to implement integration events in ES based system? Also any reference of how to implement long running process (saga) with external dependency like manual validation and timeout in event sourced system?