| ClusterShardingStartAsync Method (String, Props, ClusterShardingSettings, IdExtractor, ShardResolver, IShardAllocationStrategy, Object) |
Register a named entity type by defining the
Props of the entity actor and
functions to extract entity and shard identifier from messages. The
ShardRegion
actor for this type can later be retrieved with the
ShardRegion(String) method.
Namespace:
Akka.Cluster.Sharding
Assembly:
Akka.Cluster.Sharding (in Akka.Cluster.Sharding.dll) Version: 1.2.3.129 (1.2.3.129)
Syntax public Task<IActorRef> StartAsync(
string typeName,
Props entityProps,
ClusterShardingSettings settings,
IdExtractor idExtractor,
ShardResolver shardResolver,
IShardAllocationStrategy allocationStrategy,
Object handOffStopMessage
)
member StartAsync :
typeName : string *
entityProps : Props *
settings : ClusterShardingSettings *
idExtractor : IdExtractor *
shardResolver : ShardResolver *
allocationStrategy : IShardAllocationStrategy *
handOffStopMessage : Object -> Task<IActorRef>
Parameters
- typeName
- Type: SystemString
The name of the entity type - entityProps
- Type: Akka.ActorProps
The Props of the entity actors that will be created by the ShardRegion - settings
- Type: Akka.Cluster.ShardingClusterShardingSettings
Configuration settings, see ClusterShardingSettings - idExtractor
- Type: Akka.Cluster.ShardingIdExtractor
Partial function to extract the entity id and the message to send to the entity from the incoming message,
if the partial function does not match the message will be `unhandled`,
i.e.posted as `Unhandled` messages on the event stream
- shardResolver
- Type: Akka.Cluster.ShardingShardResolver
Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used
- allocationStrategy
- Type: Akka.Cluster.ShardingIShardAllocationStrategy
Possibility to use a custom shard allocation and rebalancing logic - handOffStopMessage
- Type: SystemObject
The message that will be sent to entities when they are to be stopped for a rebalance or
graceful shutdown of a ShardRegion, e.g. PoisonPill.
Return Value
Type:
TaskIActorRefThe actor ref of the
ShardRegion that is to be responsible for the shard.
Exceptions Exception | Condition |
---|
IllegalStateException |
This exception is thrown when the cluster member doesn't have the role specified in settings.
|
See Also