本文整理汇总了C#中NamespaceManager.GetTopic方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceManager.GetTopic方法的具体用法?C# NamespaceManager.GetTopic怎么用?C# NamespaceManager.GetTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceManager
的用法示例。
在下文中一共展示了NamespaceManager.GetTopic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AzureServiceBusMessageQueue
public AzureServiceBusMessageQueue(string connectionString, string inputQueue)
{
try
{
log.Info("Initializing Azure Service Bus transport with logical input queue '{0}'", inputQueue);
namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
InputQueue = inputQueue;
log.Info("Ensuring that topic '{0}' exists", TopicName);
if (!namespaceManager.TopicExists(TopicName))
{
try
{
namespaceManager.CreateTopic(TopicName);
}
catch
{
// just assume the call failed because the topic already exists - if GetTopic below
// fails, then something must be wrong, and then we just want to fail immediately
}
}
topicDescription = namespaceManager.GetTopic(TopicName);
log.Info("Creating topic client");
topicClient = TopicClient.CreateFromConnectionString(connectionString, topicDescription.Path);
// if we're in one-way mode, just quit here
if (inputQueue == null) return;
GetOrCreateSubscription(InputQueue);
log.Info("Creating subscription client");
subscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, TopicName, InputQueue, ReceiveMode.PeekLock);
}
catch (Exception e)
{
throw new ApplicationException(
string.Format(
"An error occurred while initializing Azure Service Bus with logical input queue '{0}'",
inputQueue), e);
}
}
示例2: Main
static void Main(string[] args)
{
GetUserCredentials();
TokenProvider tokenProvider = null;
Uri serviceUri = null;
CreateTokenProviderAndServiceUri(out tokenProvider, out serviceUri);
NamespaceManager namespaceClient = new NamespaceManager(serviceUri, tokenProvider);
var topicDescription = namespaceClient.GetTopic(TopicName);
MessagingFactory factory = null;
var topicClient1 = CreateTopicSubscriptionClient(serviceUri, tokenProvider, "AuditSubscription", ref factory);
var topicClient2 = CreateTopicSubscriptionClient(serviceUri, tokenProvider, "AgentSubscription", ref factory);
Console.WriteLine("\nReceiving messages from Topic '{0}'...", TopicName);
// Numero actual de mensagens na queue
ReceiveAllMessagesFromSubscription(topicClient1);
ReceiveAllMessagesFromSubscription(topicClient2);
Console.WriteLine("\nEnd of scenario, press ENTER to exit.");
Console.ReadLine();
}