Class HashCodeMessageExtractor<M>
java.lang.Object
org.apache.pekko.cluster.sharding.typed.ShardingMessageExtractor<ShardingEnvelope<M>,M>
org.apache.pekko.cluster.sharding.typed.HashCodeMessageExtractor<M>
- Type Parameters:
M- The type of message accepted by the entity actor
public final class HashCodeMessageExtractor<M>
extends ShardingMessageExtractor<ShardingEnvelope<M>,M>
Default message extractor type, using envelopes to identify what entity a message is for
and the hashcode of the entityId to decide which shard an entity belongs to.
This is recommended since it does not force details about sharding into the entity protocol
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionentityId(ShardingEnvelope<M> envelope) Extract the entity id from an incomingmessage.intThe shard identifier for a given entity id.unwrapMessage(ShardingEnvelope<M> envelope) Extract the message to send to the entity from an incomingmessage.Methods inherited from class org.apache.pekko.cluster.sharding.typed.ShardingMessageExtractor
apply, noEnvelope
-
Constructor Details
-
HashCodeMessageExtractor
public HashCodeMessageExtractor(int numberOfShards)
-
-
Method Details
-
entityId
Description copied from class:ShardingMessageExtractorExtract the entity id from an incomingmessage. Ifnullis returned the message will beunhandled, i.e. posted asUnhandledmessages on the event stream- Specified by:
entityIdin classShardingMessageExtractor<ShardingEnvelope<M>,M>
-
numberOfShards
public int numberOfShards() -
shardId
Description copied from class:ShardingMessageExtractorThe shard identifier for a given entity id. Only messages that passed theShardingMessageExtractor.entityId(E)function will be used as input to this function.- Specified by:
shardIdin classShardingMessageExtractor<ShardingEnvelope<M>,M>
-
unwrapMessage
Description copied from class:ShardingMessageExtractorExtract the message to send to the entity from an incomingmessage. Note that the extracted message does not have to be the same as the incoming message to support wrapping in message envelope that is unwrapped before sending to the entity actor.- Specified by:
unwrapMessagein classShardingMessageExtractor<ShardingEnvelope<M>,M>
-