In our project we have a requirement to show the change history for an action. So is it possible to query the events from an EventStore or how do we achieve this scenario using axon framework.
one way to approach this, is to simply see the “change history” as another model. You can build human interpreted message based on events that occur. This can either be done pro-actively by building an event handler, or ad-hoc by opening an event stream for an aggregate on the event store and intepreting these events as you stream then to the UI.
If you want to do more advanced queries, AxonDB allows ad-hoc queries to be executed against the event stream.
From AxonFramework itself, you currently cannot do arbitrary queries against the event store.
Hope this helps.
Thank you allard for your valuable inputs. Our application is in design phase where we are trying to follow CQRS with event sourcing. We are in dilemma whether it is a good approach to query against an event store from command side to show the change history?
conceptually, there is nothing against querying the event store to build projections. That’s exactly how the event store is supposed to be used. Whether you want to query ad-hoc or just build a projection proactively, is a question of what you optimize for. If the change history is hardly ever queried, it might be a better option to create it ad-hoc. If it’s queried a lot, it’s probably better to build is proactively.
If you want to see the change log of one of your aggregates, it’s very easy to do with the current API’s. If it’s an arbitrary concept, it might be slightly harder, but still very much doable.