From daaf83dc1b15f513f750893cf2d3e6265130b2a2 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Sun, 4 Oct 2026 22:25:06 -0500 Subject: [PATCH] Correct serializer loading and supervision documentation --- docs/articles/actors/routers.md | 2 +- docs/articles/serialization/serialization.md | 2 ++ src/core/Akka/Pattern/BackoffSupervisor.cs | 24 ++++++++++++-------- src/core/Akka/Serialization/Serializer.cs | 23 +++++++------------ 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/docs/articles/actors/routers.md b/docs/articles/actors/routers.md index 224aa322d82..dc634ef458a 100644 --- a/docs/articles/actors/routers.md +++ b/docs/articles/actors/routers.md @@ -96,7 +96,7 @@ Routers are implemented as actors, so a router is supervised by its parent, and *Pool routers* on the other hand create their own children. The router is therefore also the routee's supervisor. -By default, pool routers use a custom strategy that only returns `Escalate` for all exceptions, the router supervising the failing worker will then escalate to its own parent, if the parent of the router decides to restart the router, all the pool workers will also be recreated as a result of this. +By default, pool routers use `Pool.DefaultSupervisorStrategy`, which is `SupervisorStrategy.DefaultStrategy`. This strategy restarts a routee for ordinary exceptions and stops it for `ActorInitializationException`, `ActorKilledException`, and `DeathPactException`. ## Routing Strategies diff --git a/docs/articles/serialization/serialization.md b/docs/articles/serialization/serialization.md index 373895515bc..6937a4c129b 100644 --- a/docs/articles/serialization/serialization.md +++ b/docs/articles/serialization/serialization.md @@ -194,6 +194,8 @@ The only thing left to do for this class would be to fill in the serialization l Afterwards the configuration would need to be updated to reflect which name to bind to and the classes that use this serializer. +When dynamic type loading is enabled and a custom serializer is configured by type name under `akka.actor.serializers`, Akka.NET uses the constructor taking `(ExtendedActorSystem, Config)` when `akka.actor.serialization-settings.` is non-empty, and the constructor taking only `ExtendedActorSystem` otherwise. It does not fall back to a parameterless constructor. With `SerializationSetup`, the setup factory supplies the serializer instances in `SerializerDetails` instead. + ### Serializer Ids Serializer ids are part of the wire format: two nodes that disagree about an id cannot read each other's messages. Ids from 0 to 40 are reserved for Akka.NET. diff --git a/src/core/Akka/Pattern/BackoffSupervisor.cs b/src/core/Akka/Pattern/BackoffSupervisor.cs index 120c1f67f08..18245ffc80f 100644 --- a/src/core/Akka/Pattern/BackoffSupervisor.cs +++ b/src/core/Akka/Pattern/BackoffSupervisor.cs @@ -180,13 +180,16 @@ private bool OnTerminated(object message) } /// - /// Props for creating a actor. + /// Creates Props for a using . + /// With this legacy overload, a restarts the child immediately; + /// backoff is applied after the child terminates. /// /// The of the child actor that will be started and supervised /// Name of the child actor /// Minimum (initial) duration until the child actor will started again, if it is terminated /// The exponential back-off is capped to this duration /// After calculation of the exponential back-off an additional random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. In order to skip this additional delay pass in `0`. + /// Props configured to create a . public static Props Props( Props childProps, string childName, @@ -198,18 +201,16 @@ public static Props Props( } /// - /// Props for creating a actor. - /// - /// Exceptions in the child are handled with the default supervision strategy, i.e. - /// most exceptions will immediately restart the child. You can define another - /// supervision strategy by using [[#propsWithSupervisorStrategy]]. + /// Creates Props for a using the default supervision strategy + /// with the specified retry limit. The strategy handles child failures; backoff is applied + /// when the child terminates. /// /// The of the child actor that will be started and supervised /// Name of the child actor /// Minimum (initial) duration until the child actor will started again, if it is terminated /// The exponential back-off is capped to this duration /// After calculation of the exponential back-off an additional random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. In order to skip this additional delay pass in `0`. - /// Maximum number of attempts to restart the child actor. The supervisor will terminate itself after the maxNoOfRetries is reached. In order to restart infinitely pass in `-1`. + /// Maximum backoff restarts between automatic resets. Up to this many restarts are allowed; a child termination that would exceed this backoff restart limit stops the supervisor. The counter resets after a replacement has run for . This value also sets the separate default limit for immediate child-failure restarts. Pass -1 for no retry limit. /// A instance configured to create a . public static Props Props( Props childProps, @@ -237,14 +238,19 @@ public static Props Props(BackoffOptions options) } /// - /// Props for creating a actor with a custom supervision strategy. + /// Creates Props for a using the supplied child supervision strategy. + /// With this legacy overload, a is handled immediately by the + /// supplied strategy; backoff is applied after the child terminates. To delay restart directives, use + /// with ; + /// that path stops the child and schedules its replacement after the backoff delay. /// /// The of the child actor that will be started and supervised /// Name of the child actor /// Minimum (initial) duration until the child actor will started again, if it is terminated /// The exponential back-off is capped to this duration /// After calculation of the exponential back-off an additional random delay based on this factor is added, e.g. `0.2` adds up to `20%` delay. In order to skip this additional delay pass in `0`. - /// The supervision strategy to use for handling exceptions in the child + /// The supervision strategy used to handle child failures. For a , its retry limit also caps the backoff restart count. + /// Props configured to create a . public static Props PropsWithSupervisorStrategy( Props childProps, string childName, diff --git a/src/core/Akka/Serialization/Serializer.cs b/src/core/Akka/Serialization/Serializer.cs index 57d52d8f0e7..91eb4b95799 100644 --- a/src/core/Akka/Serialization/Serializer.cs +++ b/src/core/Akka/Serialization/Serializer.cs @@ -21,21 +21,14 @@ namespace Akka.Serialization /// /// A Serializer represents a bimap between an object and an array of bytes representing that object. /// - /// Serializers are loaded using reflection during - /// start-up, where two constructors are tried in order: - /// - ///
    - ///
  • taking exactly one argument of type ; - /// this should be the preferred one because all reflective loading of classes - /// during deserialization should use ExtendedActorSystem.dynamicAccess (see - /// [[akka.actor.DynamicAccess]]), and
  • - ///
  • without arguments, which is only an option if the serializer does not - /// load classes using reflection.
  • - ///
- /// - /// Be sure to always use the PropertyManager for loading classes! This is necessary to - /// avoid strange match errors and inequalities which arise from different class loaders loading - /// the same class. + /// When dynamic type loading is enabled, a custom serializer named by type in + /// akka.actor.serializers is created during serialization initialization. When + /// akka.actor.serialization-settings.<alias> + /// contains configuration, the loader invokes a constructor taking + /// and ; otherwise it invokes a constructor taking only + /// . There is no parameterless-constructor fallback. + /// registers serializer instances returned by its factory, + /// and those registrations are applied after the HOCON serializer entries. ///
public abstract class Serializer {