本文整理汇总了C#中NamespaceManager.DeleteTopicAsync方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceManager.DeleteTopicAsync方法的具体用法?C# NamespaceManager.DeleteTopicAsync怎么用?C# NamespaceManager.DeleteTopicAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceManager
的用法示例。
在下文中一共展示了NamespaceManager.DeleteTopicAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public async Task Run(string namespaceAddress, string manageToken)
{
// This sample demonstrates how to use advanced filters with ServiceBus topics and subscriptions.
// The sample creates a topic and 3 subscriptions with different filter definitions.
// Each receiver will receive matching messages depending on the filter associated with a subscription.
// NOTE:
// This is primarily an example illustrating the management features related to setting up
// Service Bus subscriptions. It is DISCOURAGED for applications to routinely set up and
// tear down topics and subscriptions as a part of regular message processing. Managing
// topics and subscriptions is a system configuration operation.
// Create messaging factory and ServiceBus namespace client.
var sharedAccessSignatureTokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(manageToken);
var namespaceManager = new NamespaceManager(namespaceAddress, sharedAccessSignatureTokenProvider);
Console.WriteLine("\nCreating a topic and 3 subscriptions.");
// Create a topic and several subscriptions; clean house ahead of time
if (await namespaceManager.TopicExistsAsync(TopicName))
{
await namespaceManager.DeleteTopicAsync(TopicName);
}
var topicDescription = await namespaceManager.CreateTopicAsync(TopicName);
Console.WriteLine("Topic created.");
// Create a subscription for all messages sent to topic.
await namespaceManager.CreateSubscriptionAsync(topicDescription.Path, SubscriptionAllMessages, new TrueFilter());
Console.WriteLine("Subscription {0} added with filter definition set to TrueFilter.", SubscriptionAllMessages);
// Create a subscription that'll receive all orders which have color "blue" and quantity 10.
await namespaceManager.CreateSubscriptionAsync(
topicDescription.Path,
SubscriptionColorBlueSize10Orders,
new SqlFilter("color = 'blue' AND quantity = 10"));
Console.WriteLine(
"Subscription {0} added with filter definition \"color = 'blue' AND quantity = 10\".",
SubscriptionColorBlueSize10Orders);
// Create a subscription that'll receive all orders which have color "red"
await namespaceManager.CreateSubscriptionAsync(
topicDescription.Path,
SubscriptionColorRed,
new RuleDescription
{
Name = "RedRule",
Filter = new SqlFilter("color = 'red'"),
Action = new SqlRuleAction(
"SET quantity = quantity / 2;" +
"REMOVE priority;" +
"SET sys.CorrelationId = 'low';")
});
Console.WriteLine("Subscription {0} added with filter definition \"color = 'red'\" and action definition.", SubscriptionColorRed);
// Create a subscription that'll receive all high priority orders.
namespaceManager.CreateSubscription(topicDescription.Path, SubscriptionHighPriorityOrders,
new CorrelationFilter { Label = "red", CorrelationId = "high"});
Console.WriteLine("Subscription {0} added with correlation filter definition \"high\".", SubscriptionHighPriorityOrders);
Console.WriteLine("Create completed.");
await this.SendAndReceiveTestsAsync(namespaceAddress, sharedAccessSignatureTokenProvider);
Console.WriteLine("Press [Enter] to quit...");
Console.ReadLine();
Console.WriteLine("\nDeleting topic and subscriptions from previous run if any.");
try
{
namespaceManager.DeleteTopic(TopicName);
}
catch (MessagingEntityNotFoundException)
{
Console.WriteLine("No topic found to delete.");
}
Console.WriteLine("Delete completed.");
}
示例2: Delete
public async Task Delete()
{
var namespaceManager = new NamespaceManager(_address, _settings.TokenProvider);
await namespaceManager.DeleteSubscriptionAsync(TopicName, SubscriptionName);
await namespaceManager.DeleteTopicAsync(TopicName);
}