My initial thinking is to buffer and re-order events based on their timestamp (as a fallback) within a tumbling window.
I'm still shaping my thinking and figuring out some complexities, e.g., dealing with stream-lagging-related issues.
I'm curious to know if any well-known algorithms exist to solve this.
Note: I find out that EventStoreDB already supports this (
link). But I couldn't easily see the logic behind it in the git repo :)