I need to notify an external consumer when events happen on a given stream. Since I don’t care about past events, it seems that I should just use a volatile subscription. But I do need to make sure I don’t miss any events going forward. Is there any good pattern to ensure this kind of robustness? Or am I overthinking this?
Checkpointing is the standard pattern for this.
Just have the consuming application record the stream position as it processes the stream.
That is the “checkpoint.”
Use this checkpoint when system restarts with a catchup subscription, (there is a checkpoint parameter in the client call for this purpose.)
Based on your needs you can use various level of caching and durability on saving the checkpoint.
If the output of the processor is a db write, include the checkpoint in the write transaction.
Ok, so that’s basically what we do for catchup subscriptions…so I guess I’ll just do the same, but manually start the first checkout at the end, or in code if the checkpoint is null, start at end, or something to that effect.
Persistent subscriptions handles this for you.
just make sure to explicitly ack, and have a plan for retries and timeouts.