当前位置: 首页>>代码示例>>C#>>正文


C# NamespaceManager.GetTopic方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:rlarno,项目名称:Rebus,代码行数:45,代码来源:AzureServiceBusMessageQueue.cs

示例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();

        }
开发者ID:sandrapatfer,项目名称:PROMPT11-10-CloudComputing.sandrapatfer,代码行数:23,代码来源:Program.cs


注:本文中的NamespaceManager.GetTopic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。