I have several components inside my system that establish subscriptions with the EventStore.
It works well as long as no subscription or connection has to be re-established, but if that happens, I get either none, one or multiple concurrent subscriptions.
When SubscriptionDropped is invoked, is it my job to establish a new subscription? I’d guess so, but it seems like that in some cases, either the old subscription survives (even though it said it dropped) or the ClientAPI is automatically establishing a new subscription, resulting in two/multiple subscriptions to the same stream and multiple invocations of EventAppeared for the same event.
Everything starts up, everything connects,
App has active Subscription (ID #1) to EventStore
event occurs, Subscription ID #1 invokes EventAppeared
I kill event store manually
ClientAPI invokes SubscriptionDropped for Subscription ID #1 with DropReason ConnectionClosed
I restart event store manually
App subscribes again because previous Subscription was supposedly dropped, so App has now Subscription ID #2
event occurs, Subscription ID #1 AND #2 invoke EventAppeared.
I could try to deduplicate etc. on the client-side but that would lead to multi-threading and possibly message reordering etc. and I’d guess that it shouldn’t be that hard.
Am I doing something wrong? How can I be sure a subscription is really “gone” if not based on SubscriptionDropped?
Should I only reconnect based on specific DropReasons? Although ConnectionClosed sounds severe enough to warrant a new subscription…
Server+Client: Current dev branch
Thanks in advance,