I am trying to figure out the best approach for using ES internal pub/sub capabilities.
I am using CQRS so I would like to update my read model out of process triggered on an event being written to a stream (write model). I have initially been looking into ways of subscribing to sort or a wildcard stream but this seems to be incorrect - I was looking for something like (listen where stream name = entity-*).
I have now started to look at:
creating a persistent subscription when a new stream is created (before appending event) using CreatePersistentSubscriptionAsync(…)
connect to the new subscription with ConnectToPersistentSubscription(…)
Then when my application is restarted I:
read in all persistent subscriptions using List(UserCredentials userCredentials = null)
register each via ConnectToPersistentSubscription(…)
This seems to be a much neater solution, but would like to confirm if this is inline with best practice. I do have one concern with this and that is, let’s say I have 1,000,000 streams, how do i go about managing all of these subscriptions? Surely I cannot register all of these at startup.
If anyone can point me to an online post/example that would be great, I have failed numerous times to find anything.
Thanks in advance.