Hi Roland!
Thank you very much for taking the time to answer, I really appreciate. Thank you also for your informative answer.
Our particular use case, since you kindly ask, is the following: we have adopted an approach where we keep a domain model as pure as possible, with commands, replies and events described without direct referencing to Akka types, e.g. with such definitions:
trait EntityCommand {
type Reply
}
In what we call the “infrastructure” layer, we create some wrapper message type which wraps these higher-level commands:
trait CommandExpectingReply[Command <: EntityCommand] {
val command: Command
val replyTo: ActorRef[command.Reply]
}
(for which we have an implementation similar to this)
private case class Impl[Command <: EntityCommand, R](command: Command { type Reply = R }, replyTo: ActorRef[R])
extends CommandExpectingReply[Command]
This indeed works fine locally, until we force serialization when running tests.
So I was craving for any information around how to deal with generically typed messages in a cluster environment, hence my question
If I understand well, we will indeed have to include some information with the command type, or use a completely custom serialization strategy. Seems like ClassTag
should be enough to distinguish what command type we are tackling. So if I understood well, the built-in jackson configuration in akka supports embedding ClassTag
values in messages?
Btw. if you are interested in finding out more about our motivations and our approach, we have written an article about it here: https://medium.com/bestmile/domain-driven-event-sourcing-with-akka-typed-5f5b8bbfb823
(please note that in that article, we use a slightly different typing strategy, based on type parameters rather than type members, the latter with which we are experimenting with at the moment)
Thanks again! any additional information welcome of course 