Search code examples
scalaserializationakkaakka-io

Deserialization case class from ByteString


I send case class using:

tcpActor ! Tcp.Write(MyCaseClass(arg1: Class1, arg2: Class2).data)

Then I received:

case Tcp.Receive(data: ByteString)

Is there any simple way to match data on MyCaseClass without using low level java serializer?


Solution

  • Your options:
    1. Use Akka remoting to send the case classes directly
    2. Use Java serialization
    3. Use https://github.com/scala/pickling
    4. Write your own message protocol to convert between case classes and byte strings

    Choose what best fits your use case.