Events are persisted in an unexpected order

Hello,

We are currently using Lagom 1.5.5 with Scala, and we’ve recently encountered a strange issue with the order of events in the entity.

This is what we are doing:

  1. Issue Command A to an entity, which emits Event A
  2. A readside processor has an event handler for Event A, which issues Command B to the same entity
  3. Upon receiving Command B, the entity emits Event B

In this case, we’re expecting Event A to appear before Event B on the entity. This seems to be the case all along for us, but there was a case where Event B was persisted before Event A on the entity, which resulted in some downstream issues for us.

Is there any reason why this could happen? Thanks in advance.

Hi @aloysius,

What you describe is not possible.

If the read-side processor issues Command B when it sees Event A, it means that Event A is already persisted on the journal. When Command B yields Event B, Event A is already on the journal. It’s not possible that you are seeing them out of order.

Could it be that you are mixing events from different entities? My guess is that you misinterpreted the flow events and a mixing events from two different entities.

Cheers,

Renato