Skip to content

[FLINK-37436] Fix that flink-connector-pulsar used a incorrect API when dynamically creating topics by DynamicTopicRouter #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.pulsar.client.impl.conf.ProducerConfigurationData;
import org.apache.pulsar.client.impl.transaction.TransactionImpl;
import org.apache.pulsar.common.api.proto.MessageMetadata;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.protocol.schema.SchemaHash;
import org.apache.pulsar.common.schema.SchemaType;
import org.apache.pulsar.shade.com.google.common.base.Strings;
Expand Down Expand Up @@ -218,6 +219,14 @@ private <T> Producer<T> getOrCreateProducer(String topic, Schema<T> schema)
try {
// Use this method for auto creating the non-exist topics. Otherwise, it will throw an
// exception.
TopicName topicName = TopicName.get(topic);
// Step-1: create partitioned topic metadata.
if (topicName.isPartitioned()) {
pulsarClient
.getPartitionsForTopic(TopicName.get(topic).getPartitionedTopicName())
.get();
}
// Step-2: create partition.
pulsarClient.getPartitionsForTopic(topic).get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Expand Down
Loading