Wrong order of events (TrackingProcessor)

Hello together,

in one of our current projects, we have the folloging setup:

spring boot maven @ 1.5.6
axonframework maven @ 3.0.6
mongodb as event storage and mongo db as read model store

JacksonSerializer configured with the following object mapper settings:


Some events are stored around the same second, one with 0 milliseconds and
the second some milliseconds later:

e.g. from the mongodb
{ "id:" "event1", "aggregateIdentifier": "42", "sequenceNumber": 0 "timestamp": "2017-07-17T09:08:50Z" ... }


{ "id:" "event1", "aggregateIdentifier": "42", "sequenceNumber": 1 "timestamp": "2017-07-17T09:08:50.139Z" ... }

In our event handlers in the read model using a tracking processor, the event are delivered in the
wrong order, the event 1 BEFORE the event 0.

Expected Result:
Event 0 before event 1

We don’t know exactly how the axon tracking processor determines the order of the events to replay,
but it seems that it has some problems with serialized timestamp. Is this maybe a wrong configuration
while serializing the date stamp or while deserializing.

Any help appreciated

Thanks in advance


Hi Benjamin,

the MongoEventStorageEngine does a sort based on the timestamp. Since this field is a String, it will use a text-based sort. The Z is higher than 1 (of the milliseconds), causing the second event overtake the first.
If possible, the serialized timestamp should always contain the milliseconds explicitly.

Axon does the serialization, in this case, and passes a String to Mongo. So far, I’ve always seen the millis being appended (even if they were 000). Will look into it.


Hi Allard,

thank you for your quick response, if you need more information or if I can help
you with something, let me know.

Best Regards,


Hi Benjamin,

I’ve found the issue. It’s the default formatting of Java on Instants. And because they (rightfully) add the Z for the timezone (=UTC), text based ordering of the timestamp is off when some contain millis, and some don’t.
A fix for this issue would be to explicitly provide the format to parse the instant in, and always include 3 positions for the millis.