SubscribeToStreamFrom From EventNumber of 0

Hi, guys. Since $StreamCreated has been removed from Ver2.0, how can I use SubscribeToStreamFrom to subscribe from the first event with EventNumber of 0 ?
I try to replay all the event to rebuild the read model.

Best regards.

Ziwen

CatchupSubscription does just this. Maybe its better to just use it since it handles all the catching up via reading for you?

https://github.com/EventStore/EventStore/blob/master/src/EventStore/EventStore.ClientAPI/EventStoreCatchUpSubscription.cs

Ziwen,

There’s a constant named StreamPosition.Start (iirc) which points to the start of the stream and should be used instead of specifying 0 directly. Then ignore events whose event type starts with “$” (most likely).

Cheers,

James

James

I have tried to use StreamPosition.Start but the first event appeared is EventNumber of 1.

I checked the doc again and find that it works to subscribe from start of stream if pass in null.

So maybe the StreamPosition.Start should be defined as null?

Best regards.

Ziwen

for SubscribeTo[Stream|All]From start position is exclusive, so if you want to receive everything – pass null. Passing 0 means receive everything AFTER 0.

StreamPosition.Start is 0 and this is correct as stream starts at event #0. It behaves correctly when used with usual read methods (e.g., ReadStreamForward).