EventDispatcher - storing last processed

I have been looking at ways to dispatch events, and the dispatcher in this thread seems to fit my needs nicely:

His gist here:


I see that it maintains a _lastProcessed Position, but doesn’t seem to store it permanently anywhere. I would think this would be a necessity if the dispatcher dies, etc. What would be the best way to do this? Write to a file? I honestly haven’t used flat file storage for real-time persistence, so am wondering what caveats if any I am missing in terms of best performance/safest way to store _lastProcessed.

Also, this post is from last July, so if there are better solutions, I’d love to hear about them.



  1. look at CatchupSubscription
  2. you keep track of it (if you do atomically then you simulate only once messaging)

I think the only really important thing is that it’s stored durable, since otherwise you could process messages twice. I successfully used Azure Blob Storage and Redis (not that durable :wink: ) … it’s mostly decided by the performance you need and the resources you have at hand or want to establish in your infrastructure.

Even if it’s durable you’re only at-least-once unless you store it transactionally (eg in the same SQL server transaction) with the work.

What you choose here really depends what guarantees you require?

I worked on that code quite some time ago with James and Andrii’s help. They helped me a lot, but the CatchupSubscription that Greg mentioned is the way to go. That code in the Gist isn’t battle tested. I was very appreciative of Andrii and James’s help as it got me up and running with a prototype I was working on at the time, but there are now better alternatives.


Actually the code is very similar I believe we started with the dispatcher code then improved a few things