Java Code Examples for com.google.cloud.pubsub.v1.TopicAdminClient#deleteTopic()

The following examples show how to use com.google.cloud.pubsub.v1.TopicAdminClient#deleteTopic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PubsubHelper.java    From flink with Apache License 2.0 6 votes vote down vote up
public void deleteTopic(ProjectTopicName 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);
}
 
Example 2
Source File: PubsubHelper.java    From flink with Apache License 2.0 6 votes vote down vote up
public void deleteTopic(ProjectTopicName 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);
}
 
Example 3
Source File: RealTimeFeed.java    From java-docs-samples with Apache License 2.0 4 votes vote down vote up
@AfterClass
public static void deleteTopic() throws Exception {
  TopicAdminClient topicAdminClient = TopicAdminClient.create();
  topicAdminClient.deleteTopic(topicName);
}