use of com.google.api.gax.rpc.NotFoundException in project flink by apache.
the class PubsubHelper method deleteTopic.
public void deleteTopic(TopicName topicName) throws IOException {
TopicAdminClient adminClient = getTopicAdminClient();
try {
adminClient.getTopic(topicName);
} catch (NotFoundException e) {
// Doesn't exist. Good.
return;
}
// If it exists we delete all subscriptions and the topic itself.
LOG.info("DeleteTopic {} first delete old subscriptions.", topicName);
adminClient.listTopicSubscriptions(topicName).iterateAllAsProjectSubscriptionName().forEach(subscriptionAdminClient::deleteSubscription);
LOG.info("DeleteTopic {}", topicName);
adminClient.deleteTopic(topicName);
}
use of com.google.api.gax.rpc.NotFoundException in project flink by apache.
the class PubsubHelper method deleteSubscription.
public void deleteSubscription(ProjectSubscriptionName subscriptionName) throws IOException {
SubscriptionAdminClient adminClient = getSubscriptionAdminClient();
try {
adminClient.getSubscription(subscriptionName);
// If it already exists we must first delete it.
LOG.info("DeleteSubscription {}", subscriptionName);
adminClient.deleteSubscription(subscriptionName);
} catch (NotFoundException e) {
// Doesn't exist. Good.
}
}
Aggregations