@pawelkaczor wrote:
Hi,
In some rare circumstances (I haven’t investigated it closer) I’m getting the following error when calling EventSourcedBehavior.lastSequenceNumber:akka.actor.typed.internal.BehaviorImpl$ReceiveMessageBehavior java.lang.IllegalStateException: Cannot extract the lastSequenceNumber in state akka.actor.typed.internal.BehaviorImpl$ReceiveMessageBehavior at akka.persistence.typed.scaladsl.EventSourcedBehavior$.lastSequenceNumber(EventSourcedBehavior.scala:109) at akka.persistence.typed.javadsl.EventSourcedBehavior.lastSequenceNumber(EventSourcedBehavior.scala:198)
The method lastSequenceNumber is called from the command handler (of EventSourcedBehavior) when creating effect chain with the following helper method:
protected EffectBuilder<Event, State> persist(List<Event> events) { long lastSeqNr = lastSequenceNumber(this.ctx); return Effect().persist(events).thenRun(s -> { forEach(withPosition(events), (eventPos, event) -> { long eventSeqNr = lastSeqNr + eventPos + 1; logEvent(event, eventSeqNr); }); }); }
Am I doing something wrong here?
Posts: 4
Participants: 2