Class ReplicatorMessageAdapter<A,B extends ReplicatedData>

java.lang.Object
org.apache.pekko.cluster.ddata.typed.javadsl.ReplicatorMessageAdapter<A,B>
Type Parameters:
A - Message type of the requesting actor.
B - Type of the ReplicatedData.

public class ReplicatorMessageAdapter<A,B extends ReplicatedData> extends Object
When interacting with the Replicator from an actor this class provides convenient methods that adapts the response messages to the requesting actor's message protocol.

One ReplicatorMessageAdapter instance can be used for a given ReplicatedData type, e.g. an OrSet. Interaction with several Keys can be used via the same adapter but they must all be of the same ReplicatedData type. For interaction with several different ReplicatedData types, e.g. an OrSet and a GCounter, an adapter can be created for each type.

For the default replicator in the DistributedData extension a ReplicatorMessageAdapter can be created with DistributedData.withReplicatorMessageAdapter.

*Warning*: ReplicatorMessageAdapter is not thread-safe and must only be used from the actor corresponding to the given ActorContext. It must not be accessed from threads other than the ordinary actor message processing thread, such as CompletionStage callbacks. It must not be shared between several actor instances.

param: context The pekko.actor.typed.javadsl.ActorContext of the requesting actor. The ReplicatorMessageAdapter can only be used in this actor. param: replicator The replicator to interact with, typically DistributedData.get(system).replicator. param: unexpectedAskTimeout The timeout to use for ask operations. This should be longer than the timeout given in Replicator.WriteConsistency and Replicator.ReadConsistency. The replicator will always send a reply within those timeouts so the unexpectedAskTimeout should not occur, but for cleanup in a failure situation it must still exist. If askUpdate, askGet or askDelete takes longer then this unexpectedAskTimeout a TimeoutException will be thrown by the requesting actor and may be handled by supervision.