Last week I was seeing some odd behavior in my ES client during debugging. I make a simple call to SubscribeToAllFrom, which I expect to give me a sequential stream of events, but when I set a breakpoint inside the eventAppeared handler I occasionally will see a weird concurrency situation. The same event seems to be sent to the callback twice. Since I wasn’t expecting that, my (non-thread-safe) event processing code goes kaboom.
So I have two couple of questions. (Assuming no bugs in ES/ES.Client)
- Is SubscribeToAllFrom expected to provide an exactly-once deliver guarantee for each event?
- Is SubscribeToAllFrom’s invocation of its various callbacks (eventAppeared, liveProcessingStarted, subscriptionDropped) totally sequential (meaning only one of those callbacks will ever be invoked at a time, and no other callback will be invoked until that invocation has finished), or is it totally concurrent (it doesn’t seem to be - I normally don’t get bombarded with a dozen simultaneous tasks for processing the next event), or is it partially concurrent in some way?
If the ES/ES.Client behavior isn’t what I’m expecting, I’m going to need some kind of in-memory construct to deduplicate and help with event ordering (something like a HashSet of received event IDs and a queue), but even that isn’t going to absolutely guarantee ordered delivery (though it will guarantee at-most-once delivery).
On the other hand, if the ES/ES.Client behavior is what I’m expecting, then I can try to reproduce the behavior in some sample code and hopefully you can tell me what I’m doing wrong.
Thanks!