liveBook · Manning

JacksonCborSerializer

As explained in Akka in Action, Second Edition

cbor-jackson is a serialization binding that encodes data in CBOR using Jackson-based Akka serialization support.

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

How Akka in Action, Second Edition covers it

How deep it goes
Explains dependency, configuration, trait binding, payload format, and serializer identifiers, but defers schema evolution details.
Examples
Uses master-worker CountedWords messages and CargoAdded events stored as binary journal payloads.
What it assumes
Assumes Akka actor messages and application configuration, while introducing cross-JVM serialization and marker-trait binding.
What you can do after
Operate/configure Jackson CBOR serialization for selected Akka messages and inspect its persistent event representation.
How it connects
Connects actor serialization with JacksonJsonSerializer, Protocol Buffers, event sourcing, persistence, and schema evolution.

This explainer was generated by Manning's knowledge graph from the text of Akka in Action, Second Edition. The section links point to the parts of the book it draws on.