{"id":15050631,"url":"https://github.com/virtuslab/akka-serialization-helper","last_synced_at":"2025-04-10T02:19:28.724Z","repository":{"id":37420794,"uuid":"347746667","full_name":"VirtusLab/akka-serialization-helper","owner":"VirtusLab","description":"Serialization toolbox for Akka messages, events and persistent state that helps achieve compile-time guarantee on serializability. No more errors in the runtime!","archived":false,"fork":false,"pushed_at":"2025-04-01T03:14:59.000Z","size":4521,"stargazers_count":29,"open_issues_count":19,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-10T02:19:27.245Z","etag":null,"topics":["akka","compiler-plugin","sbt-plugin","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VirtusLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-14T20:29:22.000Z","updated_at":"2025-04-02T07:52:32.000Z","dependencies_parsed_at":"2023-10-17T12:16:59.610Z","dependency_job_id":"b0ffb325-782a-4d4b-b683-611a383dc3be","html_url":"https://github.com/VirtusLab/akka-serialization-helper","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtusLab%2Fakka-serialization-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtusLab%2Fakka-serialization-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtusLab%2Fakka-serialization-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VirtusLab%2Fakka-serialization-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VirtusLab","download_url":"https://codeload.github.com/VirtusLab/akka-serialization-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142908,"owners_count":21054672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akka","compiler-plugin","sbt-plugin","scala"],"created_at":"2024-09-24T21:28:24.039Z","updated_at":"2025-04-10T02:19:28.712Z","avatar_url":"https://github.com/VirtusLab.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Akka Serialization Helper\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.virtuslab.ash/annotation_2.13/badge.svg)](https://mvnrepository.com/artifact/org.virtuslab.ash)\n[![GitHub Actions](https://github.com/VirtusLab/akka-serialization-helper/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/VirtusLab/akka-serialization-helper/actions)\n[![License: MIT](https://img.shields.io/github/license/VirtusLab/akka-serialization-helper)](LICENSE)\n\n![logo-ash-horizontal](logo/ash/svg/logo-ash-horizontal.svg#gh-light-mode-only)\n![logo-ash-horizontal](logo/ash/svg/logo-ash-horizontal-dark-bg.svg#gh-dark-mode-only)\n\nSerialization toolbox for Akka messages, events and persistent state that helps achieve compile-time guarantee on\nserializability. There are some Akka serialization caveats this tool can help with:\n1. [Missing serialization binding](#missing-serialization-binding)\n2. [Incompatibility of persistent data](#incompatibility-of-persistent-data)\n3. [Jackson Akka Serializer](#jackson-akka-serializer)\n4. [Missing Codec registration](#missing-codec-registration)\n\n\u003c!-- \u003cPEKKO-REMOVE-START\u003e ---\u003e\n# ⚠️ Check [pekko-serialization-helper](https://github.com/VirtusLab/pekko-serialization-helper) for Pekko ⚠️\n\u003c!-- \u003cPEKKO-REMOVE-END\u003e ---\u003e\n\n## Install\n\nAdd the following line to `plugins.sbt` (take `Version` from the above Maven badge or [GitHub Releases](https://github.com/VirtusLab/akka-serialization-helper/releases)):\n\n```scala\naddSbtPlugin(\"org.virtuslab.ash\" % \"sbt-akka-serialization-helper\" % Version)\n```\n\nand enable the sbt plugin in the target project:\n```scala\nlazy val app = (project in file(\"app\"))\n  .enablePlugins(AkkaSerializationHelperPlugin)\n```\n\n## Missing serialization binding\n\nTo serialize message, persistent state or event in Akka, Scala trait needs to be defined:\n\n```scala\npackage org\ntrait MySer\n```\n\nAlso, a serializer needs to be bound to this trait in a configuration file:\n\n```scala\nakka.actor {\n  serializers {\n    jackson-json = \"akka.serialization.jackson.JacksonJsonSerializer\"\n  }\n  serialization-bindings {\n    \"org.MySer\" = jackson-json\n  }\n}\n```\n\nThe [problem](#appendix-b-what-happens-with-serialization-of-messages--events--states-that-do-not-extend-a-base-trait-bound-to-a-serializer) occurs if a class is not extended with the base trait bound to the serializer:\n\n```scala\ntrait MySer\ncase class MyMessage() // extends MySer\n```\n\n`akka-serialization-helper` to the rescue! It detects messages, events and persistent states, and checks whether they\nextend the given base trait and report an error when they don't. This ensures that the specified serializer is\nused by Akka and protects against an unintended fallback to\n[Java serialization](https://doc.akka.io/docs/akka/current/serialization.html#java-serialization) or outright\nserialization failure.\n\nTo use, base trait should be annotated with [`@org.virtuslab.ash.SerializabilityTrait`](annotation/src/main/scala/org/virtuslab/ash/annotation/SerializabilityTrait.scala):\n\n```scala\n@SerializabilityTrait\ntrait MySerializable\n```\n\nIt allows catching errors like these:\n```scala\nimport akka.actor.typed.Behavior\n\nobject BehaviorTest {\n  sealed trait Command //extends MySerializable\n  def method(msg: Command): Behavior[Command] = ???\n}\n```\n\nAnd results in a compile error, preventing non-runtime-safe code from being executed:\n```\ntest0.scala:7: error: org.random.project.BehaviorTest.Command is used as Akka message\nbut does not extend a trait annotated with org.virtuslab.ash.annotation.SerializabilityTrait.\nPassing an object of a class that does NOT extend a trait annotated with SerializabilityTrait as a message may cause Akka to\nfall back to Java serialization during runtime.\n\n\n  def method(msg: Command): Behavior[Command] = ???\n                            ^\ntest0.scala:6: error: Make sure this type is itself annotated, or extends a type annotated\nwith  @org.virtuslab.ash.annotation.SerializabilityTrait.\n  sealed trait Command extends MySerializable\n               ^\n```\n\n\nThe compiler plugin only checks the classes in the sbt modules where `AkkaSerializationHelperPlugin` is explicitly enabled.\nIt may happen that the base trait (like `MySerializable` in the example) lives in an sbt module like `core` where the plugin\nshould **not** be enabled (e.g. for compilation performance reasons).\nHowever, `MySerializable` needs to be annotated with `org.virtuslab.ash.SerializabilityTrait`.\nIn order to have access to the `SerializabilityTrait` annotation without enabling the entire suite of compiler plugins,\nadd `AkkaSerializationHelperPlugin.annotation` to `libraryDependencies`:\n\n```scala\nimport org.virtuslab.ash.AkkaSerializationHelperPlugin\n\nlazy val core = (project in file(\"core\"))\n  .settings(libraryDependencies += AkkaSerializationHelperPlugin.annotation)\n```\n\n## Incompatibility of persistent data\n\n![Typical tragic story](docs/typical-tragic-story.png)\n\nA typical problem with a persistence is when the already persisted data is not compatible\nwith the schemas defined in a new version of the application.\n\nTo solve this, a mix of a compiler plugin and an sbt task can be used for dumping schema\nof [akka-persistence](https://doc.akka.io/docs/akka/current/typed/persistence.html#example-and-core-api) to a\nfile. It can be used for detecting accidental changes of events (journal) and states (snapshots) with a simple `diff`.\n\nTo dump persistence schema for each sbt module where `AkkaSerializationHelperPlugin` is enabled, run:\n\n```shell\nsbt ashDumpPersistenceSchema\n```\n\nDefault file is `target/\u003csbt-module-name\u003e-dump-persistence-schema-\u003cversion\u003e.yaml` (`target/` of top-level module!) but it can be changed using sbt keys:\n```scala\nashDumpPersistenceSchemaOutputFilename := \"file.yaml\" // Changes filename\nashDumpPersistenceSchemaOutputDirectoryPath := \"~\" // Changes directory\n```\n\n#### Example dump\n```yaml\n- name: org.random.project.Data\n  typeSymbol: trait\n- name: org.random.project.Data.ClassTest\n  typeSymbol: class\n  fields:\n  - name: a\n    typeName: java.lang.String\n  - name: b\n    typeName: scala.Int\n  - name: c\n    typeName: scala.Double\n  parents:\n  - org.random.project.Data\n- name: org.random.project.Data.ClassWithAdditionData\n  typeSymbol: class\n  fields:\n  - name: ad\n    typeName: org.random.project.Data.AdditionalData\n  parents:\n  - org.random.project.Data\n```\n\nA `diff` command can be used to check the difference between the version of a schema from `develop`/`main` branch and the\nversion from the current commit.\n\n![Easy to diff](docs/easy-to-diff.png)\n\n\n## Jackson Akka Serializer\n\nUsing Jackson Serializer for akka-persistence is also one of the pitfalls and this\nplugin provides an alternative by using a serializer that uses [Circe](https://circe.github.io/circe/).\n\nDangerous code for Jackson:\n\n```scala\ncase class Message(animal: Animal) extends MySer\n\nsealed trait Animal\n\nfinal case class Lion(name: String) extends Animal\nfinal case class Tiger(name: String) extends Animal\n```\n\nTo make this code work, a lot of Jackson annotations should be added:\n\n```scala\ncase class Message(animal: Animal) extends MultiDocPrintService\n\n@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = \"type\")\n@JsonSubTypes(\n  Array(\n    new JsonSubTypes.Type(value = classOf[Lion], name = \"lion\"),\n    new JsonSubTypes.Type(value = classOf[Tiger], name = \"tiger\")))\nsealed trait Animal\n\nfinal case class Lion(name: String) extends Animal\nfinal case class Tiger(name: String) extends Animal\n\n```\n\nAlso if an object is defined:\n```scala\ncase object Tick\n```\n\nThere will not be exceptions during serialization but Jackson will create\nanother instance of `Tick` instead of restoring the `object Tick`'s underlying singleton.\n\n```scala\nactorRef ! Tick\n\n// Inside the actor:\ndef receive = {\n  case Tick =\u003e // this won't get matched\n} // message will be unhandled\n```\n\nA [Circe-based](https://circe.github.io/circe/) Akka serializer can be used. It uses Circe codecs, derived using [Shapeless](https://circe.github.io/circe/codecs/auto-derivation.html),\nthat are generated during compile time (so serializer won't crash during runtime as reflection-based serializers may do).\nFor a comparison of Circe with other serializers, read [Appendix A](#appendix-a-comparison-of-available-akka-serializers).\n\nNote that it is **not** obligatory to use this serializer for the other features (serializability checker, persistence schema dump) to work.\nThey work as well with e.g. when [Jackson serializer](https://doc.akka.io/docs/akka/current/serialization-jackson.html) is selected.\n\n#### Usage\n\nAdd the following to project dependencies:\n\n```scala\nimport org.virtuslab.ash.AkkaSerializationHelperPlugin\n\nlazy val app = (project in file(\"app\"))\n  // ...\n  .settings(libraryDependencies += AkkaSerializationHelperPlugin.circeAkkaSerializer)\n```\n\nNote that enabling `AkkaSerializationHelperPlugin` does **not** add Circe serializer to the classpath automatically,\nas this sbt plugin can be used to improve safety of other serializers as well.\n\nCreate a custom serializer by extending `CirceAkkaSerializer` base class:\n```scala\nimport org.virtuslab.ash.circe.CirceAkkaSerializer\n\nclass ExampleSerializer(actorSystem: ExtendedActorSystem)\n    extends CirceAkkaSerializer[MySerializable](actorSystem) {\n\n  override def identifier: Int = 41\n\n  override lazy val codecs = Seq(Register[CommandOne], Register[CommandTwo])\n\n  override lazy val manifestMigrations = Nil\n\n  override lazy val packagePrefix = \"org.project\"\n}\n```\n`CirceAkkaSerializer` can be configured to use Gzip compression when serializing payloads greater than defined size (default is without compression).\n\nSee [default reference.conf file](circe-akka-serializer/src/main/resources/reference.conf) with comments for more details about `CirceAkkaSerializer` configuration.\n\nFor more guidelines on how to use the serializer,\nread [Akka documentation about serialization](https://doc.akka.io/docs/akka/current/serialization.html),\n[`CirceAkkaSerializer`](circe-akka-serializer/src/main/scala/org/virtuslab/ash/circe/CirceAkkaSerializer.scala) Scaladoc\nand look at the [examples](examples).\n\n## Missing Codec registration\n\nIf a codec is not registered, a runtime exception will occur.\n```scala\nimport org.virtuslab.ash.circe.CirceAkkaSerializer\nimport org.virtuslab.ash.circe.Register\n\nclass ExampleSerializer(actorSystem: ExtendedActorSystem)\n  extends CirceAkkaSerializer[MySerializable](actorSystem) {\n  // ...\n  override lazy val codecs = Seq(Register[CommandOne]) // WHOOPS someone forgot to register CommandTwo...\n}\n```\n```shell\njava.lang.RuntimeException: Serialization of [CommandTwo] failed. Call Register[A]\nfor this class or its supertype and append result to `def codecs`.\n```\n\nTo solve that, an annotation\n[`@org.virtuslab.ash.Serializer`](annotation/src/main/scala/org/virtuslab/ash/annotation/Serializer.scala)\ncan be used.\n\nDuring compilation, the plugin gathers all direct descendants of the class marked with [`@org.virtuslab.ash.SerializabilityTrait`](annotation/src/main/scala/org/virtuslab/ash/annotation/SerializabilityTrait.scala)\nand checks the body of classes annotated with [`@org.virtuslab.ash.Serializer`](annotation/src/main/scala/org/virtuslab/ash/annotation/Serializer.scala) if they reference all these direct descendants in any way.\n\nIn practice, this is used for checking a class extending [CirceAkkaSerializer](circe-akka-serializer/src/main/scala/org/virtuslab/ash/circe/CirceAkkaSerializer.scala), like this:\n\n```scala\nimport org.virtuslab.ash.circe.CirceAkkaSerializer\nimport org.virtuslab.ash.circe.Register\n\n@Serializer(\n  classOf[MySerializable],\n  typeRegexPattern = Register.REGISTRATION_REGEX)\nclass ExampleSerializer(actorSystem: ExtendedActorSystem)\n  extends CirceAkkaSerializer[MySerializable](actorSystem) {\n    // ...\n    override lazy val codecs = Seq(Register[CommandOne]) // WHOOPS someone forgot to register CommandTwo...\n    // ... but Codec Registration Checker will throw a compilation error here:\n    // `No codec for `CommandOne` is registered in a class annotated with @org.virtuslab.ash.annotation.Serializer`\n}\n```\n\nNote that as with Serializability Checker and Dump Persistence Schema,\nthis compiler plugin only runs in the sbt modules where `AkkaSerializationHelperPlugin` is explicitly enabled.\n\nFor more information, read [`@Serializer` scaladoc](annotation/src/main/scala/org/virtuslab/ash/annotation/Serializer.scala).\n\n## Additional configuration for compiler plugins\n\nAll compiler plugins and their verbose modes can be enabled/disabled using two sbt keys:\n\n```scala\nashCompilerPluginEnable := false // default is true\nashCompilerPluginVerbose := true // default is false\n```\n\nThis can be done for all compiler plugins, like above, or just one:\n```scala\nashCodecRegistrationCheckerCompilerPlugin / ashCompilerPluginEnable := false\nashDumpPersistenceSchemaCompilerPlugin / ashCompilerPluginVerbose := true\n```\n\nAdditionally, `Compile` and `Test` scope can be specified:\n\n```scala\nCompile / ashDumpPersistenceSchemaCompilerPlugin / ashCompilerPluginVerbose := true\nTest / ashCompilerPluginEnable := false\n```\n\nFor full list of sbt keys, check [`org.virtuslab.ash.AkkaSerializationHelperKeys`](sbt-akka-serialization-helper/src/main/scala/org/virtuslab/ash/AkkaSerializationHelperKeys.scala).\n\n## Example applications\nThe simplest example is the akka-cluster application which uses Akka Serialization Helper: [akka-cluster-app](examples/akka-cluster-app).\n\nThe second example is the akka-persistence application which shows usage of the Dump Persistence Schema Compiler Plugin: [akka-persistence-app](examples/akka-persistence-app).\n\n## Step-by-step guide\nSee [full step-by-step guide](docs/GUIDE.md) on Akka Serialization Helper usage.\n\n## Contributing Guide\n\nIf you want to contribute to this project, see [Contributing Guide](CONTRIBUTING.md).\n\n## Appendix A: Comparison of available Akka Serializers\n\n| Serializer             | [Jackson](https://github.com/FasterXML/jackson)                                                                                                                                                                                                                                                                                                                                                                                                    | [Circe](https://circe.github.io/circe/)                                                                                                                                                                                                                    | [Protobuf v3](https://developers.google.com/protocol-buffers)                                                                                                                                                                                       | [Avro](https://avro.apache.org/docs/current/)                                                                                                                                        | [Borer](https://github.com/sirthias/borer)                                                                                        | [Kryo](https://github.com/EsotericSoftware/kryo)                                                          |\n|:-----------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------|\n| Data formats           | JSON or [CBOR](https://cbor.io)                                                                                                                                                                                                                                                                                                                                                                                                                    | JSON                                                                                                                                                                                                                                                       | JSON or custom binary                                                                                                                                                                                                                               | JSON or custom binary                                                                                                                                                                | JSON or CBOR                                                                                                                      | custom binary                                                                                             |\n| Scala support          | very poor, even with [jackson-module-scala](https://github.com/FasterXML/jackson-module-scala): \u003cul\u003e\u003cli\u003epoor support for Scala objects, without configuration (without adding ScalaObjectDeserializerModule usage) creates new instances of singleton types (`Foo$`), breaking pattern matching\u003c/li\u003e\u003cli\u003elacks support of basic scala types like `Unit`\u003c/li\u003e\u003cli\u003ewithout explicit annotation doesn't work with generics extending `AnyVal`\u003c/li\u003e\u003c/ul\u003e | perfect out of the box                                                                                                                                                                                                                                     | perfect with [ScalaPB](https://scalapb.github.io)                                                                                                                                                                                                   | perfect with [Avro4s](https://github.com/sksamuel/avro4s)                                                                                                                            | perfect out of the box                                                                                                            | perfect out of the box                                                                                    |\n| Akka support           | [akka-serialization-jackson](https://doc.akka.io/docs/akka/current/serialization-jackson.html)                                                                                                                                                                                                                                                                                                                                                     | [serializer provided by this project](#jackson-akka-serializer)                                                                                                                                                                                            | used by [akka-remote](https://doc.akka.io/docs/akka/current/serialization.html) internally                                                                                                                                                          | requires custom serializer                                                                                                                                                           | requires custom serializer                                                                                                        | [akka-kryo](https://github.com/altoo-ag/akka-kryo-serialization)                                          |\n| Compile-time mechanics | nothing happens in compile time; everything based on runtime reflection                                                                                                                                                                                                                                                                                                                                                                            | derives codecs via [Shapeless](https://circe.github.io/circe/codecs/auto-derivation.html)                                                                                                                                                                  | with ScalaPB, generates Scala classes based on \\*.proto files                                                                                                                                                                                       | with Avro4s, derives Avro schemas using [Magnolia](https://github.com/softwaremill/magnolia)                                                                                         | derives codecs **without** Magnolia                                                                                               | with akka-kryo, optionally derives codecs in compile time, but otherwise uses reflection in runtime       |\n| Runtime safety         | none, uses reflection                                                                                                                                                                                                                                                                                                                                                                                                                              | encoders and decoders are created during compilation                                                                                                                                                                                                       | \\*.proto files are validated before compilation                                                                                                                                                                                                     | Avro schema is created during compilation                                                                                                                                            | encoders and decoders are created during compilation                                                                              | depends on whether codecs were derived in compile time (then standard for Scala code), or not (than none) |\n| Boilerplate            | a lot: \u003cul\u003e\u003cli\u003eADTs requires amount of annotation equal to or exceeding the actual type definitions\u003c/li\u003e\u003cli\u003erequires explicit serializers and deserializers in certain cases (e.g. enums)\u003c/li\u003e\u003c/ul\u003e                                                                                                                                                                                                                                                | every top-level sealed trait must be registered manually - but see [Codec Registration Checker](#missing-codec-registration)                                                                                                                               | in case of custom types, a second layer of models is needed                                                                                                                                                                                         | sometimes requires annotations                                                                                                                                                       | every top-level sealed trait must be registered manually; every transitively included class must have an explicitly defined codec | every top-level sealed trait must be registered manually                                                  |\n| Schema evolution       | \u003cul\u003e\u003cli\u003eremoving field\u003c/li\u003e\u003cli\u003eadding optional field\u003c/li\u003e\u003c/ul\u003e with [`JacksonMigration`](https://doc.akka.io/docs/akka/current/serialization-jackson.html#schema-evolution): \u003cul\u003e\u003cli\u003eadding mandatory field\u003c/li\u003e\u003cli\u003erenaming field\u003c/li\u003e\u003cli\u003erenaming class\u003c/li\u003e\u003cli\u003esupport of forward versioning for rolling updates\u003c/li\u003e\u003c/ul\u003e                                                                                                                      | \u003cul\u003e\u003cli\u003eadding optional field\u003c/li\u003e\u003cli\u003eremoving optional field\u003c/li\u003e\u003cli\u003eadding required field with default value\u003c/li\u003e\u003cli\u003eremoving required field\u003c/li\u003e\u003cli\u003erenaming field\u003c/li\u003e\u003cli\u003ereordering fields\u003c/li\u003e\u003cli\u003etransforming data before deserialization\u003c/li\u003e\u003c/ul\u003e | \u003cul\u003e\u003cli\u003eadding optional field\u003c/li\u003e\u003cli\u003eremoving optional field\u003c/li\u003e\u003cli\u003eadding required field with default value\u003c/li\u003e\u003cli\u003eremoving required field\u003c/li\u003e\u003cli\u003erenaming field\u003c/li\u003e\u003cli\u003ereordering fields\u003c/li\u003e\u003cli\u003echanging between compatible types\u003c/li\u003e\u003c/ul\u003e | \u003cul\u003e\u003cli\u003ereordering fields\u003c/li\u003e\u003cli\u003erenaming fields\u003c/li\u003e\u003cli\u003eadding optional field\u003c/li\u003e\u003cli\u003eadding required field with default value\u003c/li\u003e\u003cli\u003eremoving field with default value\u003c/li\u003e\u003c/ul\u003e | \u003cul\u003e\u003cli\u003erenaming fields\u003c/li\u003e\u003cli\u003etransforming data before deserialization\u003c/li\u003e\u003c/ul\u003e                                                | \u003cul\u003e\u003cli\u003eadding field\u003c/li\u003e\u003cli\u003eremoving field\u003c/li\u003e\u003cli\u003erenaming field\u003c/li\u003e\u003cli\u003erenaming class\u003c/li\u003e\u003c/ul\u003e       |\n\n## Appendix B: what happens with serialization of Messages / Events / States that do not extend a base trait bound to a serializer\n\nIn runtime, if given Message/Event/State class does not extend a base trait bound to a serializer, the following problems will occur (depending on Akka version and settings):\n\n\u003c!-- \u003cPEKKO-REMOVE-START\u003e ---\u003e\n**Note** - the default setting for Akka 2.5 is `akka.actor.allow-java-serialization=on`, whereas `akka.actor.allow-java-serialization=off` is the default setting for Akka 2.6\n\n| Akka version                                | `akka.actor.allow-java-serialization=off`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | `akka.actor.allow-java-serialization=on`                                                                                                                                                                                                                                                                                                                                                                                                                    |\n|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 2.5 | Serialization will fail with logs like below:\u003cbr\u003e\u003cbr\u003e```[WARN] [...] Outgoing message attempted to use Java Serialization even though `akka.actor.allow-java-serialization = off` was set! Message type was: [class sample.cluster.transformation.BackendRegistration$]```\u003cbr\u003e\u003cbr\u003e ```[ERROR] [...] Failed to serialize remote message [class akka.actor.ActorSelectionMessage] using serializer [class akka.remote.serialization.MessageContainerSerializer]. Transient association error (association remains live)```\u003cbr\u003e\u003cbr\u003e```akka.remote.MessageSerializer$SerializationException: Failed to serialize remote message```\u003cbr\u003e ```[class akka.actor.ActorSelectionMessage] using serializer [class akka.remote.serialization.MessageContainerSerializer].```\u003cbr\u003e ```at akka.remote.MessageSerializer$.serialize(MessageSerializer.scala:67)```\u003cbr\u003e ```at akka.remote.EndpointWriter.$anonfun$serializeMessage$1(Endpoint.scala:1021)```\u003cbr\u003e ```at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)```\u003cbr\u003e ```at akka.remote.EndpointWriter.serializeMessage(Endpoint.scala:1021)```\u003cbr\u003e ```at akka.remote.EndpointWriter.writeSend(Endpoint.scala:887)```\u003cbr\u003e ```at akka.remote.EndpointWriter$$anonfun$4.applyOrElse(Endpoint.scala:859)```\u003cbr\u003e ```at akka.actor.Actor.aroundReceive(Actor.scala:539)```\u003cbr\u003e ```at akka.actor.Actor.aroundReceive$(Actor.scala:537)```\u003cbr\u003e ```at akka.remote.EndpointActor.aroundReceive(Endpoint.scala:536)```\u003cbr\u003e ```at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612)```\u003cbr\u003e ```at akka.actor.ActorCell.invoke(ActorCell.scala:581)```\u003cbr\u003e ```at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)```\u003cbr\u003e ```at akka.dispatch.Mailbox.run(Mailbox.scala:229)```\u003cbr\u003e ```at akka.dispatch.Mailbox.exec(Mailbox.scala:241)```\u003cbr\u003e ```at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)```\u003cbr\u003e ```at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)```\u003cbr\u003e ```at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)```\u003cbr\u003e ```at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)```\u003cbr\u003e ```Caused by: akka.serialization.DisabledJavaSerializer$JavaSerializationException: Attempted to serialize message using Java serialization while `akka.actor.allow-java-serialization` was disabled. Check WARNING logs for more details.``` | Serialization succeeds - but using Java serialization (which is not a good choice for production). Warning log like below will appear on the startup:\u003cbr\u003e\u003cbr\u003e ```[WARN] [...] Using the default Java serializer for class [sample.cluster.transformation.TransformationResult] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage'```                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n| 2.6 | Serialization will fail with logs like below:\u003cbr\u003e\u003cbr\u003e ```[WARN] [...] - Outgoing message attempted to use Java Serialization even though`akka.actor.allow-java-serialization = off` was set! Message type was: [class sample.cluster.transformation.Worker$TransformText]```\u003cbr\u003e\u003cbr\u003e ```[ERROR] [...] - Failed to serialize message [sample.cluster.transformation.Worker$TransformText]. akka.serialization.DisabledJavaSerializer$JavaSerializationException: Attempted to serialize message using Java serialization while `akka.actor.allow-java-serialization` was disabled. Check WARNING logs for more details```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Serialization succeeds - but using Java serialization (which is not a good choice for production). Warning log like below will appear on the startup:\u003cbr\u003e\u003cbr\u003e ```[WARN] [...] Using the default Java serializer for class [sample.cluster.transformation.TransformationResult] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage'``` |\n\u003c!-- \u003cPEKKO-REMOVE-END\u003e ---\u003e\n\n\u003c!-- \u003cPEKKO-UNCOMMENT-START\u003e ---\u003e\n\u003c!-- **Note** - the default setting for Pekko 1.x is `pekko.actor.allow-java-serialization=off` --\u003e\n\n\u003c!-- | Pekko version | `pekko.actor.allow-java-serialization=off`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | `pekko.actor.allow-java-serialization=on`                                                                                                                                                                                                                                                                                                                                                                                                                       | --\u003e\n\u003c!-- |---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --\u003e\n\u003c!-- | 1.x           | Serialization will fail with logs like below:\u003cbr\u003e\u003cbr\u003e ```[WARN] [...] - Outgoing message attempted to use Java Serialization even though`pekko.actor.allow-java-serialization = off` was set! Message type was: [class sample.cluster.transformation.Worker$TransformText]```\u003cbr\u003e\u003cbr\u003e ```[ERROR] [...] - Failed to serialize message [sample.cluster.transformation.Worker$TransformText]. pekko.serialization.DisabledJavaSerializer$JavaSerializationException: Attempted to serialize message using Java serialization while `pekko.actor.allow-java-serialization` was disabled. Check WARNING logs for more details``` | Serialization succeeds - but using Java serialization (which is not a good choice for production). Warning log like below will appear on the startup:\u003cbr\u003e\u003cbr\u003e ```[WARN] [...] Using the default Java serializer for class [sample.cluster.transformation.TransformationResult] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'pekko.actor.warn-about-java-serializer-usage'``` | --\u003e\n\u003c!-- \u003cPEKKO-UNCOMMENT-END\u003e ---\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtuslab%2Fakka-serialization-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtuslab%2Fakka-serialization-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtuslab%2Fakka-serialization-helper/lists"}