Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java DSL throws exception when using typed.javadsl.EventSourcedBehavior#lastSequenceNumber #32433

Open
aludwiko opened this issue May 27, 2024 · 2 comments

Comments

@aludwiko
Copy link
Contributor

When handling the first event in the event handler:

java.lang.IllegalStateException: Cannot extract the lastSequenceNumber in state akka.actor.typed.internal.BehaviorImpl$DeferredBehavior$$anon$1
	at akka.persistence.typed.scaladsl.EventSourcedBehavior$.lastSequenceNumber(EventSourcedBehavior.scala:115)
	at akka.persistence.typed.javadsl.EventSourcedBehavior.lastSequenceNumber(EventSourcedBehavior.scala:263)
	at perf.test.iot.DeviceEntity.eventHandler(DeviceEntity.java:82)
	at akka.persistence.typed.javadsl.EventSourcedBehavior.createEventSourcedBehavior(EventSourcedBehavior.scala:224)
	at akka.persistence.typed.javadsl.EventSourcedBehavior.apply(EventSourcedBehavior.scala:207)

I think that pattern matching should also cover Deferred wrapper:
image

@aludwiko aludwiko changed the title Java DSL throws exception when using akka.persistence.typed.javadsl.EventSourcedBehavior#lastSequenceNumber Java DSL throws exception when using typed.javadsl.EventSourcedBehavior#lastSequenceNumber May 27, 2024
@johanandren
Copy link
Member

When handling the first event in the event handler

On replay, or after handling a command?

@johanandren
Copy link
Member

For the record, Deferred means the behavior was not created yet, it just contains a factory context => behavior, so there is no way to look "inside" it.

Can you share exactly what the event handler method looks like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants