JacksonCborSerializer encodes actor messages as compact binary CBOR so actors communicating across JVMs or machines can exchange bytes instead of in-memory objects. It offers slightly better throughput and smaller output than JacksonJsonSerializer, with simpler setup than Protocol Buffers. section 8.5.1
Configure the serializer in three steps:
- Add the akka-serialization-jackson dependency. section 8.5.1
- Register JacksonCborSerializer under the jackson-cbor serializer name. section 8.5.1
- Bind a marker trait such as CborSerializable to jackson-cbor, then mix that trait into every message requiring serialization. section 8.5.1
Master and worker messages
A CountedWords message extending Event with CborSerializable can travel between a master and its workers. In persistent actors, the same binding stores event payloads as binary data; the jackson-cbor serializer uses event_ser_id 33, while JSON remains directly readable in the database. section 8.5.1 section 9.4
akka {
actor {
serializers {
jackson-json = "akka.serialization.jackson.JacksonJsonSerializer" #1
jackson-cbor = "akka.serialization.jackson.JacksonCborSerializer" #2
}
}
}
View the Akka serializer declarations used to select Jackson JSON or CBOR. section 8.5.1
serialization-bindings {
"example.countwords.CborSerializable" = jackson-cbor #1
}
View the binding that maps CborSerializable messages to jackson-cbor. section 8.5.1
