Serialization options for Java services

You do not need to handle serialization for messages. Akka Serverless functions serve gRPC interfaces, and the input and output messages are protobuf messages that get serialized to the protobuf format. However, for objects to be persisted such as Event Sourced events and snapshots you have a choice.

By default, Akka Serverless will automatically detect if an emitted event or snapshot is a protobuf and handle them correctly, so we recommend using the default behavior. However, if you have specific requirements, you also can choose between primitive type and JSON (JavaScript Object Notation) serialization.

Akka Serverless functions serve gRPC interfaces, and the input and output messages get serialized to the protobuf format. However, in addition to these messages, Akka Serverless serializes other objects for persistence such as Event Sourced events and Entity snapshots. Akka Serverless supports protobuf, primitive type, and JSON serialization options for these values.

By default, Akka Serverless detects and handles protobuf, so we recommend using that unless you have requirements that are better met by using JSON.

Primitive types

Akka Serverless supports serializing the following primitive types:

Protobuf type Java type

string

java.lang.String

bytes

com.google.protobuf.ByteString

int32

java.lang.Integer

int64

java.lang.Long

float

java.lang.Float

double

java.lang.Double

bool

java.lang.Boolean

JSON

Akka Serverless uses Jackson to serialize JSON. Any classes that are annotated with @Jsonable will be serialized to and from JSON using Jackson.