Please consider this (thought in progress):
I store key/values for an aggregate to abstract from frequently and commonly used business data (JPA persistence). So for aggregate “1”, I execute AddValueCommand(“foo”, “world”) and can select value “foo” via graphQL from the projection model.
Now I update the value via AddValueCommand(“foo”, “hello”) … the projection is updated as well. So far so good.
But: I have the requirement that I can access historic values, so I query for “give me values for foo and bar for last Monday”.
Of course I have the metadata timestamp with the command/event handlers, but I wonder, what the best implementation would be.
1.) have Map of key,value,timestamp in Memory iterate with filter timestamp < :timestamp and reduce to latest value
2.) have an SQL table projection and do some fancy select foo where timestamp < :timestamp order by timestamp desc
Both would require manual implementation and (unnecessary?) filtering of all the data is not latest or in before given timestamp.
Since I already have the eventstore, maybe this can be done using “replay until timestamp” or “snapshot at midnight” … but its unclear to me
a) how this could be build and
b) if the performance is good enough when I constantly replay aggregate states for timestamps and just use a few of its properties in the graphQL return (not building a high performance system, its more or less a key/value cache, but non-the-less)
Has this been done before using axon eventstore? If so: how? Or is this a job for another tool?
Thanks for pointing me in the right direction.
Jan