use of org.apache.pulsar.client.api.KeySharedPolicy in project flink-mirror by flink-ci.
the class PulsarPartitionSplitReaderBase method createPulsarConsumer.
/**
* Create a specified {@link Consumer} by the given topic partition.
*/
protected Consumer<byte[]> createPulsarConsumer(TopicPartition partition) {
ConsumerBuilder<byte[]> consumerBuilder = createConsumerBuilder(pulsarClient, Schema.BYTES, sourceConfiguration);
consumerBuilder.topic(partition.getFullTopicName());
// Add KeySharedPolicy for Key_Shared subscription.
if (sourceConfiguration.getSubscriptionType() == SubscriptionType.Key_Shared) {
KeySharedPolicy policy = KeySharedPolicy.stickyHashRange().ranges(partition.getPulsarRange());
consumerBuilder.keySharedPolicy(policy);
}
// Create the consumer configuration by using common utils.
return sneakyClient(consumerBuilder::subscribe);
}
Aggregations