Class ConsistentHashingRoutingLogic
This class contains logic used by a Router to route a message to a Routee determined using consistent-hashing. This process has the router select a routee based on a message's consistent hash key. There are 3 ways to define the key, which can be used individually or combined to form the key. The ConsistentHashMapping is tried first.
- You can define a ConsistentHashMapping or use WithHashMapping(ConsistentHashMapping) of the router to map incoming messages to their consistent hash key. This makes the decision transparent for the sender.
- Messages may implement IConsistentHashable. The hash key is part of the message and it's convenient to define it together with the message definition.
- The message can be wrapped in a ConsistentHashableEnvelope to define what data to use for the consistent hash key. The sender knows what key to use.
Implements
Inherited Members
Namespace: Akka.Routing
Assembly: Akka.dll
Syntax
public sealed class ConsistentHashingRoutingLogic : RoutingLogic, INoSerializationVerificationNeeded
Constructors
| Improve this Doc View SourceConsistentHashingRoutingLogic(ActorSystem)
Initializes a new instance of the ConsistentHashingRoutingLogic class.
note
A ConsistentHashingRoutingLogic configured in this way uses the Akka.Routing.ConsistentHashingRouter.EmptyConsistentHashMapping as the hash mapping function with a virtual node factor of 0 (zero).
Declaration
public ConsistentHashingRoutingLogic(ActorSystem system)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | system | The actor system that owns the router with this logic. |
ConsistentHashingRoutingLogic(ActorSystem, Int32, ConsistentHashMapping)
Initializes a new instance of the ConsistentHashingRoutingLogic class.
Declaration
public ConsistentHashingRoutingLogic(ActorSystem system, int virtualNodesFactor, ConsistentHashMapping hashMapping)
Parameters
Type | Name | Description |
---|---|---|
ActorSystem | system | The actor system that owns the router with this logic. |
Int32 | virtualNodesFactor | The number of virtual nodes to use on the hash ring. |
ConsistentHashMapping | hashMapping | The consistent hash mapping function to use on incoming messages. |
Methods
| Improve this Doc View SourceSelect(Object, Routee[])
Picks a Routee to receive the message
.
Declaration
public override Routee Select(object message, Routee[] routees)
Parameters
Type | Name | Description |
---|---|---|
Object | message | The message that is being routed |
Routee[] | routees | A collection of routees to choose from when receiving the |
Returns
Type | Description |
---|---|
Routee | A Routee that receives the |
Overrides
| Improve this Doc View SourceWithHashMapping(ConsistentHashMapping)
Creates a new ConsistentHashingRoutingLogic router logic with a given ConsistentHashMapping.
note
This method is immutable and returns a new instance of the router.
Declaration
public ConsistentHashingRoutingLogic WithHashMapping(ConsistentHashMapping mapping)
Parameters
Type | Name | Description |
---|---|---|
ConsistentHashMapping | mapping | The ConsistentHashMapping used to configure the new router. |
Returns
Type | Description |
---|---|
ConsistentHashingRoutingLogic | A new router logic with the provided |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | This exception is thrown if the given |