本文整理汇总了C#中NamespaceManager.DeleteTopic方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceManager.DeleteTopic方法的具体用法?C# NamespaceManager.DeleteTopic怎么用?C# NamespaceManager.DeleteTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceManager
的用法示例。
在下文中一共展示了NamespaceManager.DeleteTopic方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
GetUserCredentials();
TokenProvider tokenProvider = null;
Uri serviceUri = null;
CreateTokenProviderAndServiceUri(out tokenProvider, out serviceUri);
NamespaceManager namespaceManager = new NamespaceManager(serviceUri, tokenProvider);
Console.WriteLine("Creating Topic 'IssueTrackingTopic'...");
if (namespaceManager.TopicExists("IssueTrackingTopic"))
namespaceManager.DeleteTopic("IssueTrackingTopic");
MessagingFactory factory = null;
TopicDescription myTopic = namespaceManager.CreateTopic(TopicName);
// Criar duas Subscrições
Console.WriteLine("Creating Subscriptions 'AuditSubscription' and 'AgentSubscription'...");
SubscriptionDescription myAuditSubscription = namespaceManager.CreateSubscription((myTopic.Path, "AuditSubscription");
SubscriptionDescription myAgentSubscription = namespaceManager.CreateSubscription(myTopic.Path, "AgentSubscription");
TopicClient myTopicClient = CreateTopicClient(serviceUri, tokenProvider, myTopic, out factory);
List<BrokeredMessage> messageList = new List<BrokeredMessage>();
messageList.Add(CreateIssueMessage("1", "First message information"));
messageList.Add(CreateIssueMessage("2", "Second message information"));
messageList.Add(CreateIssueMessage("3", "Third message information"));
Console.WriteLine("\nSending messages to topic...");
SendListOfMessages(messageList, myTopicClient);
Console.WriteLine("\nFinished sending messages, press ENTER to clean up and exit.");
myTopicClient.Close();
Console.ReadLine();
namespaceManager.DeleteTopic(TopicName);
}
示例2: DeleteTopicsAndSubscriptions
static void DeleteTopicsAndSubscriptions(NamespaceManager namespaceManager)
{
Console.WriteLine("\nDeleting topic and subscriptions from previous run if any.");
try
{
namespaceManager.DeleteTopic(Program.TopicName);
}
catch (MessagingEntityNotFoundException)
{
Console.WriteLine("No topic found to delete.");
}
Console.WriteLine("Delete completed.");
}
示例3: 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.");
}
示例4: RemoveAllExistingNamespaceElements
/// <summary>
/// Danger! Danger, Will Robinson!
/// </summary>
private static void RemoveAllExistingNamespaceElements(NamespaceManager namespaceManager)
{
var tasks = new List<Task>();
var queuePaths = namespaceManager.GetQueues().Select(q => q.Path).ToArray();
queuePaths
.Do(queuePath => tasks.Add(Task.Run(() => namespaceManager.DeleteQueue(queuePath))))
.Done();
var topicPaths = namespaceManager.GetTopics().Select(t => t.Path).ToArray();
topicPaths
.Do(topicPath => tasks.Add(Task.Run(() => namespaceManager.DeleteTopic(topicPath))))
.Done();
tasks.WaitAll();
}
示例5: RemoveAllExistingNamespaceElements
/// <summary>
/// Danger! Danger, Will Robinson!
/// </summary>
private static void RemoveAllExistingNamespaceElements(NamespaceManager namespaceManager, ILogger logger)
{
logger.Debug("Removing all existing namespace elements. IMPORTANT: This should only be done in your regression test suites.");
var tasks = new List<Task>();
var queuePaths = namespaceManager.GetQueues().Select(q => q.Path).ToArray();
queuePaths
.Do(queuePath => tasks.Add(Task.Run(() => namespaceManager.DeleteQueue(queuePath))))
.Done();
var topicPaths = namespaceManager.GetTopics().Select(t => t.Path).ToArray();
topicPaths
.Do(topicPath => tasks.Add(Task.Run(() => namespaceManager.DeleteTopic(topicPath))))
.Done();
tasks.WaitAll();
}
示例6: DeleteTopicsAndSubscriptions
static void DeleteTopicsAndSubscriptions(NamespaceManager namespaceManager)
{
try
{
namespaceManager.DeleteTopic(Conts.TopicName);
}
catch { }
}