Is using the event timestamp a reliable way to deal with eventual consistency

Hi,

I have a question about dealing with eventual consistency.
Is the following a reliable/good way to do this with Axon or is there a better way?

Problem:
A query model is used as the source for a view.
When the view is presented and saved, some new events are generated and the query model is updated.
When the view is presented again, the event from the previous saving of the view have to be processed in the query model.

Solution:
I would like to verify that the events are processed in the query model, by storing the timestamp of the last processed event in the query model (by using @Timestamp).
So when the view is presented the time of saving the previous view is compared to the stored timestamp of the last processed event in the query model with a certain margin.

I am using axon 3.0, with a simple command bus and tracking eventprocessors. So I think all events are processed sequentially.

Kind regards,

Erwin

Hi Erwin,

be very careful with using timestamps for this purpose. First of all, time is not forward-only. At least not from the perspective of a computer. Furthermore, it’s possible that different machines have a different time. Thirdly, even when you use the tracking processor, it is not guaranteed that the order of the events you process is the order in which they were generated or even saved into the store. That guarantee is only given on a per-aggregate basis. A DomainEventMessage always contains the sequence number, which is guaranteed to be ordered for each aggregate. If possible, that would be a much safer value to use.

But I suppose you’re trying to solve some other problem, for which this mechanism is a solution. I haven’t seen the need for something like this before. Obviously, I haven’t seen all use cases ;-), but it may also mean there is an easier solution to what you’re trying to do.

Cheers,

Allard