public class PartitionHandler extends Object
Constructor and Description |
---|
PartitionHandler(org.springframework.expression.EvaluationContext evaluationContext,
ProducerProperties properties,
org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
Construct a
PartitionHandler . |
PartitionHandler(org.springframework.expression.EvaluationContext evaluationContext,
ProducerProperties properties,
PartitionKeyExtractorStrategy partitionKeyExtractorStrategy,
PartitionSelectorStrategy partitionSelectorStrategy)
Deprecated.
since 3.0.2. Please use another constructor which allows you to pass an instance of beanFactory
|
Modifier and Type | Method and Description |
---|---|
int |
determinePartition(org.springframework.messaging.Message<?> message)
Determine the partition to which to send this message.
|
void |
setPartitionCount(int partitionCount)
Set the actual partition count (if different to the configured count).
|
@Deprecated 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 PartitionHandler(org.springframework.expression.EvaluationContext evaluationContext, ProducerProperties properties, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
PartitionHandler
.evaluationContext
- evaluation context for binderproperties
- binder propertiesbeanFactory
- instance of ConfigurableListableBeanFactorypublic void setPartitionCount(int partitionCount)
partitionCount
- the count.public 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 © 2020 Pivotal Software, Inc.. All rights reserved.