Catchup Subscription


I’m trying to use SubscribeToStreamFrom to build my read models. Writing a windows service to subscribe to the streams that will process the events (<-- is this an OK approach or some thing else is favoured?).

The SubscriptToStreamFrom method expects the event number. However, it seems it actually works on the Stream position. Where do I get that value from to store so that next time I can process the next event. EventStoreCatchUpSubscription does not seem to have the LastProcessedEventNumber that EventStoreStreamCatchupSubscription has.

The other question is, do I unsubscribe (stop) the subscription each time and subscribe again to process the next event?



The only time you should be resubscribing is on subscription lost /
restarts of your client (eg client remember the last event sequence
you processed and hands it back on a restart).

Thanks Greg.

In that example

Console.WriteLine("Received: " + x.Event.EventStreamId + “:” + x.Event.EventNumber);

Is Event.EventNumber the thing I got to hang on to when I restart?


Just to be clear thats assuming no linktos etc OriginalPosition is safe to use with either

ah! Yes, so I don’t get the event data (Event.Data) unless I pass resolvelinktos=true.

by the way I am testing this off of the $ce- projections…

yes otherwise your event data will be what is actually in the stream which is a $> event with a body 1734@somestream resolve linkto will resolve that event

That does make sense. But in this case i.e. resolvelinkto= true, the event number does not seem correct. It is being repeated. I have 3 events on my aggregate…for each event it retains the value 0,1,2 in the $ce- projection. I want the $ce event number not the actual event number (which I am only getting when resolvetolink=false).

See previous post about using OriginalEventNumber that works in both cases.

That works.

Much appreciated, thank you.