use of org.apache.pulsar.client.api.SubscriptionType.Exclusive in project flink by apache.
the class PulsarRuntimeOperator method createConsumer.
@SuppressWarnings("unchecked")
private <T> Consumer<T> createConsumer(String topic, Schema<T> schema) throws PulsarClientException {
TopicName topicName = TopicName.get(topic);
String name = topicName.getPartitionedTopicName();
int index = topicName.getPartitionIndex();
ConcurrentHashMap<Integer, Consumer<?>> topicConsumers = consumers.computeIfAbsent(name, d -> new ConcurrentHashMap<>());
return (Consumer<T>) topicConsumers.computeIfAbsent(index, i -> {
try {
return client().newConsumer(schema).topic(topic).subscriptionName(SUBSCRIPTION_NAME).subscriptionMode(Durable).subscriptionType(Exclusive).subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe();
} catch (PulsarClientException e) {
sneakyThrow(e);
return null;
}
});
}
use of org.apache.pulsar.client.api.SubscriptionType.Exclusive in project flink by splunk.
the class PulsarRuntimeOperator method createConsumer.
@SuppressWarnings("unchecked")
private <T> Consumer<T> createConsumer(String topic, Schema<T> schema) throws PulsarClientException {
TopicName topicName = TopicName.get(topic);
String name = topicName.getPartitionedTopicName();
int index = topicName.getPartitionIndex();
ConcurrentHashMap<Integer, Consumer<?>> topicConsumers = consumers.computeIfAbsent(name, d -> new ConcurrentHashMap<>());
return (Consumer<T>) topicConsumers.computeIfAbsent(index, i -> {
try {
return client().newConsumer(schema).topic(topic).subscriptionName(SUBSCRIPTION_NAME).subscriptionMode(Durable).subscriptionType(Exclusive).subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe();
} catch (PulsarClientException e) {
sneakyThrow(e);
return null;
}
});
}
use of org.apache.pulsar.client.api.SubscriptionType.Exclusive in project flink-mirror by flink-ci.
the class PulsarRuntimeOperator method createConsumer.
@SuppressWarnings("unchecked")
private <T> Consumer<T> createConsumer(String topic, Schema<T> schema) throws PulsarClientException {
TopicName topicName = TopicName.get(topic);
String name = topicName.getPartitionedTopicName();
int index = topicName.getPartitionIndex();
ConcurrentHashMap<Integer, Consumer<?>> topicConsumers = consumers.computeIfAbsent(name, d -> new ConcurrentHashMap<>());
return (Consumer<T>) topicConsumers.computeIfAbsent(index, i -> {
try {
return client().newConsumer(schema).topic(topic).subscriptionName(SUBSCRIPTION_NAME).subscriptionMode(Durable).subscriptionType(Exclusive).subscriptionInitialPosition(SubscriptionInitialPosition.Earliest).subscribe();
} catch (PulsarClientException e) {
sneakyThrow(e);
return null;
}
});
}
Aggregations