public class PartitionHandler extends Object
Constructor and Description |
---|
PartitionHandler(org.springframework.expression.EvaluationContext evaluationContext,
ProducerProperties properties,
PartitionKeyExtractorStrategy partitionKeyExtractorStrategy,
PartitionSelectorStrategy partitionSelectorStrategy)
Construct a
PartitionHandler . |
Modifier and Type | Method and Description |
---|---|
int |
determinePartition(org.springframework.messaging.Message<?> message)
Determine the partition to which to send this message.
|
public PartitionHandler(org.springframework.expression.EvaluationContext evaluationContext, ProducerProperties properties, PartitionKeyExtractorStrategy partitionKeyExtractorStrategy, PartitionSelectorStrategy partitionSelectorStrategy)
PartitionHandler
.evaluationContext
- evaluation context for binderproperties
- binder propertiespartitionKeyExtractorStrategy
- PartitionKeyExtractor strategypartitionSelectorStrategy
- PartitionSelector strategypublic int determinePartition(org.springframework.messaging.Message<?> message)
If a partition key extractor class is provided, it is invoked to determine the key. Otherwise, the partition key expression is evaluated to obtain the key value.
If a partition selector class is provided, it will be invoked to determine the
partition. Otherwise, if the partition expression is not null, it is evaluated
against the key and is expected to return an integer to which the modulo function
will be applied, using the partitionCount
as the divisor. If no partition
expression is provided, the key will be passed to the binder partition strategy
along with the partitionCount
. The default partition strategy uses
key.hashCode()
, and the result will be the mod of that value.
message
- the message.Copyright © 2019 Pivotal Software, Inc.. All rights reserved.