Lagom Persistent Entity's command or event class changed

338 views
Skip to first unread message

Roman

unread,
Aug 22, 2017, 3:36:12 AM8/22/17
to Lagom Framework Users
In case of changing entity's class there is an ability to override entityTypeName. But in case of changing command's or event's class, that don't have a such propery cause no extending PersistentEntity class. How to refactor code in such case?
For example, we have the following entity class:
public class UserEntity extends PersistentEntity<UserCommand, UserEvent, User> {
...
}

And now we'd like to move UserCommand and UserEvent classes to another package. When do that the error is traced:
[ERROR] from com.lightbend.lagom.internal.javadsl.persistence.PersistentEntityActor in ecs-user-service-akka.actor.default-dispatcher-18 - Persistence failure when replaying events for persistenceId [UserEntitybda2d45f-0b0c-3184-8342-a441eab3b19a]. Last known sequence number [0]
java
.io.NotSerializableException: Cannot find manifest class [com.idbs.ecs.ur.api.UserAddedEvent] for serializer [com.lightbend.lagom.internal.jackson.JacksonJsonSerializer].
...

Is it possible to do properly in Lagom world?

James Roper

unread,
Aug 22, 2017, 11:45:46 PM8/22/17
to Roman, Lagom Framework Users
You need to define migrations when you change the class name or schema of events or state:

https://www.lagomframework.com/documentation/1.3.x/java/Serialization.html#Schema-Evolution

The same migrations will actually work for commands too (anything that's implementing Jsonable, since the migration support is handled in the Jackson serializer).

--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/5bc8bbb4-df7e-4f71-995d-78d862c93318%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Roman

unread,
Aug 24, 2017, 5:49:49 AM8/24/17
to Lagom Framework Users, roman.ry...@gmail.com
James,

Thanks for your replay, will get in mind! 
For now, we decided just to revert the changes.
Reply all
Reply to author
Forward
0 new messages