1

Problem: I have used the cake pattern to build a system of components (traits) which define a family of types and specialise them covariantly (cf., family polymorphism). Then I have defined a component which defines some actors and messages to be exchanged among these actors.

trait BasicTypes {
    type T1 <: T1Interface
    type T2 <: T2Interface

    // other stuff
}

trait MyActors { self: BasicTypes =>
  case class Msg1(v1: T1, v2: T2)
  case class Msg2(name: String)

  class MyActor { ... }
}

The problem is that the cake gets larger, possibly including non-serializable stuff. The result is a number of akka.remote.MessageSerializer$SerializationExceptions.

Questions:

  • Is there any way to fix this without flattening the design (i.e., while keeping the Cake pattern)?
  • May I implement custom serialisation using writeObject and readObject for case classes?
  • How can I avoid the serialisation of the 'outer object' of my messages?
metaphori
  • 2,681
  • 1
  • 21
  • 32
  • Maybe I am a bit off, but it could be that Java is serialising your messages and due to bad performance you might get these exceptions, but hard to tell without seeing the stack trace. Have you checked out this: https://doc.akka.io/docs/akka/2.5/serialization.html#programmatic ? – Juan Stiza Mar 20 '18 at 18:00

0 Answers0