Sponsorship is available! If you’d like to sponsor CodeOpinion.com and have your product or service advertised exclusively (no AdSense) on every post, contact me.In my previous blog post, I talked about Catch-Up Subscriptions in-comparison to Persistent Subscriptions in Event Store. I’ve been meaning to create a little demo as I didn’t find very much in my limited searching. Specifically, I wanted to create a console app that would contain the subscription client and another console app (event writer) that would write events to a stream. This way you could run the subscription client multiple times, then run the event writer and see how the events are only received from one subscription client.
SourceAll the source code for this demo is available on GitHub. Please take a look to follow along as the rest of this post is describing how it works. Although I’ve added this to as a new repo on GitHub, It is also available in the EventStore.Samples.DotNet repo on GitHub along with other subscription model examples.
ServerIf you don’t have it already, download a copy of Event Store and run EventStore.ClusterNode.exe with default arguments. This will start the Event Store server under port 1113. The web UI will be accessible via http://localhost:2113
Create SubscriptionFirst you need to create a subscription to a stream. You will also provide a group name which you will also use when connecting to the subscription. In my demo I’ve included code to create the subscription. This is simply because I don’t want anyone running the demo to have to create it manually. The documentation discourages it from being created in your general application code.
Normally the creating of the subscription group is not done in your general executable code. Instead it is normally done as a step during an install or as an admin task when setting things up. You should assume the subscription exists in your code.The web UI has a pretty nice interface for viewing your subscriptions as well as creating and updating them.