Class Entity<M,E>
- java.lang.Object
-
- akka.cluster.sharding.typed.scaladsl.Entity<M,E>
-
public final class Entity<M,E> extends java.lang.Object
Props
of the entity actors, such as dispatcher settings.
-
-
Constructor Summary
Constructors Constructor Description Entity(scala.Function1<EntityContext,Behavior<M>> createBehavior, EntityTypeKey<M> typeKey, scala.Option<M> stopMessage, Props entityProps, scala.Option<ClusterShardingSettings> settings, scala.Option<ShardingMessageExtractor<E,M>> messageExtractor, scala.Option<ShardCoordinator.ShardAllocationStrategy> allocationStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description scala.Option<ShardCoordinator.ShardAllocationStrategy>
allocationStrategy()
static <M> Entity<M,ShardingEnvelope<M>>
apply(EntityTypeKey<M> typeKey, scala.Function1<EntityContext,Behavior<M>> createBehavior)
scala.Function1<EntityContext,Behavior<M>>
createBehavior()
Props
entityProps()
scala.Option<ShardingMessageExtractor<E,M>>
messageExtractor()
scala.Option<ClusterShardingSettings>
settings()
scala.Option<M>
stopMessage()
EntityTypeKey<M>
typeKey()
Entity<M,E>
withAllocationStrategy(ShardCoordinator.ShardAllocationStrategy newAllocationStrategy)
Allocation strategy which decides on which nodes to allocate new shards,ClusterSharding.defaultShardAllocationStrategy(akka.cluster.sharding.typed.ClusterShardingSettings)
is used if this is not specified.Entity<M,E>
withEntityProps(Props newEntityProps)
<Envelope> Entity<M,Envelope>
withMessageExtractor(ShardingMessageExtractor<Envelope,M> newExtractor)
If amessageExtractor
is not specified the messages are sent to the entities by wrapping them inShardingEnvelope
with the entityId of the recipient actor.Entity<M,E>
withSettings(ClusterShardingSettings newSettings)
Additional settings, typically loaded from configuration.Entity<M,E>
withStopMessage(M newStopMessage)
Message sent to an entity to tell it to stop, e.g.
-
-
-
Constructor Detail
-
Entity
public Entity(scala.Function1<EntityContext,Behavior<M>> createBehavior, EntityTypeKey<M> typeKey, scala.Option<M> stopMessage, Props entityProps, scala.Option<ClusterShardingSettings> settings, scala.Option<ShardingMessageExtractor<E,M>> messageExtractor, scala.Option<ShardCoordinator.ShardAllocationStrategy> allocationStrategy)
-
-
Method Detail
-
apply
public static <M> Entity<M,ShardingEnvelope<M>> apply(EntityTypeKey<M> typeKey, scala.Function1<EntityContext,Behavior<M>> createBehavior)
-
createBehavior
public scala.Function1<EntityContext,Behavior<M>> createBehavior()
-
typeKey
public EntityTypeKey<M> typeKey()
-
stopMessage
public scala.Option<M> stopMessage()
-
entityProps
public Props entityProps()
-
settings
public scala.Option<ClusterShardingSettings> settings()
-
messageExtractor
public scala.Option<ShardingMessageExtractor<E,M>> messageExtractor()
-
allocationStrategy
public scala.Option<ShardCoordinator.ShardAllocationStrategy> allocationStrategy()
-
withSettings
public Entity<M,E> withSettings(ClusterShardingSettings newSettings)
Additional settings, typically loaded from configuration.- Parameters:
newSettings
- (undocumented)- Returns:
- (undocumented)
-
withStopMessage
public Entity<M,E> withStopMessage(M newStopMessage)
Message sent to an entity to tell it to stop, e.g. when rebalanced or passivated. If this is not defined it will be stopped automatically. It can be useful to define a custom stop message if the entity needs to perform some asynchronous cleanup or interactions before stopping.- Parameters:
newStopMessage
- (undocumented)- Returns:
- (undocumented)
-
withMessageExtractor
public <Envelope> Entity<M,Envelope> withMessageExtractor(ShardingMessageExtractor<Envelope,M> newExtractor)
If amessageExtractor
is not specified the messages are sent to the entities by wrapping them inShardingEnvelope
with the entityId of the recipient actor. That envelope is used by theHashCodeMessageExtractor
for extracting entityId and shardId. The number of shards is then defined bynumberOfShards
inClusterShardingSettings
, which by default is configured withakka.cluster.sharding.number-of-shards
.- Parameters:
newExtractor
- (undocumented)- Returns:
- (undocumented)
-
withAllocationStrategy
public Entity<M,E> withAllocationStrategy(ShardCoordinator.ShardAllocationStrategy newAllocationStrategy)
Allocation strategy which decides on which nodes to allocate new shards,ClusterSharding.defaultShardAllocationStrategy(akka.cluster.sharding.typed.ClusterShardingSettings)
is used if this is not specified.- Parameters:
newAllocationStrategy
- (undocumented)- Returns:
- (undocumented)
-
-