Before subscribing to EventStoreDb, I retrieve the last known position and then I use the EventStoreClient
to subscribe to all from that position (gRPC client).
Is there any way to validate that a position really exists in order to subscribe or fallback to default position 0?
Probably it’s not very common to remember a “last position” that might be invalid after some time (unless events are removed from ESDB or the cluster subscribing to is different), but if there is already a way,
but I have noticed that eventStoreClient.SubscribeToAllAsync(position, eventAppeared)
method does not throw any exception if the position is invalid, nor the StreamSubscription
result contains any flag indicating that the start position was invalid.
The subscription seems to happen, but it won’t receive any events.
Would verifying the position in advance be a valid suggestion?
If the position is 0 it works fine, catches up from the beginning. If the position is 1, 2, 100 or other (similar?) it crashes. If the position is a random number such as 12345 or 66666 it doesn’t crash, but won’t receive any event.