• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TopicDescription类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TopicDescription的典型用法代码示例。如果您正苦于以下问题:C# TopicDescription类的具体用法?C# TopicDescription怎么用?C# TopicDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TopicDescription类属于命名空间,在下文中一共展示了TopicDescription类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TopicShouldExistAsync

 private async static Task TopicShouldExistAsync(NamespaceManager ns, TopicDescription topicDescription)
 {
     if (!await ns.TopicExistsAsync(topicDescription.Path))
     {
         throw new MessagingEntityNotFoundException("Topic: " + topicDescription.Path);
     }
 }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:7,代码来源:MessagingFactoryTopicExtensions.cs


示例2: Main

        static void Main(string[] args)
        {
            NamespaceManager manager = NamespaceManager.Create(); // Automatycznie bierze informacje z App.config
            //Wolę na początku - wygodniej "zaczynamy" zawsze od zera
            manager.DeleteTopic("obliczenia"); //Kasuje temat i subskrypcje
            manager.DeleteQueue("wynik");

            //Tworzenie Topics - tematu
            TopicDescription td = new TopicDescription("obliczenia");

            //Nie przewidujemy dużego ruchu nie wymagamy partycjonowania
            td.EnablePartitioning = false;
            //Wymagamy wykrywania duplikatów - by klient 2 razy nie wysłał tego samego polecenia
            td.RequiresDuplicateDetection = true;
            //Nie pozwalamy na tematy tylko w pamięci; chcemy żeby klient był pewien że wysłał wiadomość = wiadomość zostanie przetworzona
            td.EnableExpress = false;
            manager.CreateTopic(td); //Tworzenie tematu

            //Suma i średnia będzie wyliczana gdy opowiednia własciwość zostanie zdefiniowana
            manager.CreateSubscription("obliczenia", "suma", new SqlFilter("suma=1"));
            manager.CreateSubscription("obliczenia", "srednia", new SqlFilter("srednia=1"));
            //Ale zawsze będą liczone elementy w komunikacie
            manager.CreateSubscription("obliczenia", "liczba");

            QueueDescription qd = new QueueDescription("wynik");
            qd.RequiresSession = true;
            manager.CreateQueue(qd);
        }
开发者ID:tkopacz,项目名称:MVAFY15-Topic-Queue-ServiceBus,代码行数:28,代码来源:Program.cs


示例3: Equals

 public bool Equals(TopicDescription other)
 {
     if (ReferenceEquals(null, other))
         return false;
     if (ReferenceEquals(this, other))
         return true;
     return Equals(other.Path, Path);
 }
开发者ID:jglozano,项目名称:MassTransit-AzureServiceBus,代码行数:8,代码来源:TopicDescriptionImpl.cs


示例4: EnsureTopicAsync

        public async static Task<TopicClient> EnsureTopicAsync(this MessagingFactory factory, TopicDescription topicDescription)
        {
            await new NamespaceManager(factory.Address, factory.GetSettings().TokenProvider)
                .TryCreateEntity(
                    mgr => TopicCreateAsync(mgr, topicDescription),
                    mgr => TopicShouldExistAsync(mgr, topicDescription));

            return factory.CreateTopicClient(topicDescription.Path);
        }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:9,代码来源:MessagingFactoryTopicExtensions.cs


示例5: TopicCreateAsync

        private async static Task TopicCreateAsync(NamespaceManager ns, TopicDescription topicDescription)
        {
            if (!await ns.TopicExistsAsync(topicDescription.Path))
            {
                await ns.CreateTopicAsync(topicDescription);

                ServiceBusEventSource.Log.CreatedTopic(ns.Address.ToString(), topicDescription.Path);
            }
        }
开发者ID:RobinSoenen,项目名称:RedDog,代码行数:9,代码来源:MessagingFactoryTopicExtensions.cs


示例6: GetTopicSubscription

        public static TopicSubscriptionSettings GetTopicSubscription(this IMessageNameFormatter messageNameFormatter, Type messageType)
        {
            bool temporary = IsTemporaryMessageType(messageType);

            var topicDescription = new TopicDescription(messageNameFormatter.GetMessageName(messageType).ToString());

            var binding = new TopicSubscription(topicDescription);

            return binding;
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:10,代码来源:ServiceBusTopicSubscriptionExtensions.cs


示例7: EventTopicPublisher

        public EventTopicPublisher(string connectionString, TopicDescription topic, ITimeProvider timeProvider, ILogger logger)
        {
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.TopicExists(topic.Path))
                namespaceManager.CreateTopic(topic);

            _client = TopicClient.CreateFromConnectionString(connectionString, topic.Path);
            _timeProvider = timeProvider;
            _logger = logger;
        }
开发者ID:RagtimeWilly,项目名称:Astro.CQRS,代码行数:11,代码来源:EventTopicPublisher.cs


示例8: CreateTopicSafeAsync

        public static async Task<TopicDescription> CreateTopicSafeAsync(this NamespaceManager namespaceManager, TopicDescription topicDescription)
        {
            bool create = true;
            try
            {
                topicDescription = await namespaceManager.GetTopicAsync(topicDescription.Path);

                create = false;
            }
            catch (MessagingEntityNotFoundException)
            {
            }

            if (create)
            {
                bool created = false;
                try
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Creating topic {0}", topicDescription.Path);

                    topicDescription = await namespaceManager.CreateTopicAsync(topicDescription);

                    created = true;
                }
                catch (MessagingEntityAlreadyExistsException)
                {
                }
                catch (MessagingException mex)
                {
                    if (mex.Message.Contains("(409)"))
                    {
                    }
                    else
                        throw;
                }

                if (!created)
                    topicDescription = await namespaceManager.GetTopicAsync(topicDescription.Path);
            }

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Topic: {0} ({1})", topicDescription.Path,
                    string.Join(", ", new[]
                    {
                        topicDescription.EnableExpress ? "express" : "",
                        topicDescription.RequiresDuplicateDetection ? "dupe detect" : "",
                    }.Where(x => !string.IsNullOrWhiteSpace(x))));
            }

            return topicDescription;
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:53,代码来源:NamespaceManagerExtensions.cs


示例9: CreateTopicIfDoesntExist

 public TopicClient CreateTopicIfDoesntExist(string topicName, long sizeInMb, TimeSpan timeToLive)
 {
     if (_namespaceManager.TopicExists(topicName) == false)
     {
         var qd = new TopicDescription(topicName)
         {
             MaxSizeInMegabytes = sizeInMb,
             DefaultMessageTimeToLive = timeToLive
         };
         _namespaceManager.CreateTopic(qd);
     }
     return _messagingFactory.CreateTopicClient(topicName);
 }
开发者ID:mikkelhm,项目名称:UnicornWeb,代码行数:13,代码来源:MessageWrapper.cs


示例10: CreateTopicIfDoesntExistSilent

        public void CreateTopicIfDoesntExistSilent(string topicName, long sizeInMb, TimeSpan timeToLive)
        {
            if (!_namespaceManager.TopicExists(topicName))
            {
                var availabilityQd = new TopicDescription(topicName)
                {
                    MaxSizeInMegabytes = sizeInMb,
                    DefaultMessageTimeToLive = timeToLive
                };

                _namespaceManager.CreateTopic(availabilityQd);
            }
        }
开发者ID:mikkelhm,项目名称:UnicornWeb,代码行数:13,代码来源:MessageWrapper.cs


示例11: RunAsync

        /// <summary>
        /// Run Async
        /// </summary>
        /// <returns>Task</returns>
        public override async Task RunAsync()
        {
            var exists = await this.manager.TopicExistsAsync(name);
            if (!exists)
            {
                var td = new TopicDescription(name)
                {
                    EnableExpress = true,
                };

                await this.manager.CreateTopicAsync(td);
            }
        }
开发者ID:modulexcite,项目名称:King.Service.ServiceBus,代码行数:17,代码来源:InitializeTopic.cs


示例12: CreateTopicClient

 /// <summary>
 ///     Creates a topic client, as well as the target topic if it does not already exist.
 /// </summary>
 public static TopicClient CreateTopicClient(
     this ServiceBusSettings settings,
     string topicName,
     Action<TopicDescription> configure = null)
 {
     topicName = topicName.PrefixedIfConfigured(settings);
     var topicDescription = new TopicDescription(topicName);
     if (configure != null)
     {
         configure(topicDescription);
     }
     settings.CreateTopicIfDoesNotAlreadyExist(topicDescription);
     return TopicClient.CreateFromConnectionString(settings.ConnectionString, topicName);
 }
开发者ID:halakaraki,项目名称:Its.Cqrs,代码行数:17,代码来源:ServiceBusConfigurer.cs


示例13: Init

        public static void Init(IEnumerable<string> nodes, ref List<QueueClient> queueClients, out TopicClient topicClient, out QueueClient frontendClient)
        {
            // Node Events Queues
            foreach (var connectionString in nodes.Select(CloudConfigurationManager.GetSetting))
            {
                if (string.IsNullOrWhiteSpace(connectionString))
                {
                    throw new NotImplementedException("Connection String can not be blank");
                }

                var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
                if (!namespaceManager.QueueExists(ServiceBusPathNames.ServiceBusEventQueue))
                {
                    namespaceManager.CreateQueue(ServiceBusPathNames.ServiceBusEventQueue);
                }

                queueClients.Add(QueueClient.CreateFromConnectionString(connectionString, ServiceBusPathNames.ServiceBusEventQueue));
            }

            var workerConn = CloudConfigurationManager.GetSetting(ServiceBusConnectionStrings.WorkerServiceBusConnection);
            var workerNamespace = NamespaceManager.CreateFromConnectionString(workerConn);

            if (string.IsNullOrWhiteSpace(workerConn))
            {
                throw new NotImplementedException("Connection String can not be blank");
            }

            // Update Node Topic
            if (!workerNamespace.TopicExists(ServiceBusPathNames.ServiceBusUpdateTopic))
            {
                var td = new TopicDescription(ServiceBusPathNames.ServiceBusUpdateTopic)
                {
                    DefaultMessageTimeToLive = new TimeSpan(0, 1, 0) // TTL 1 minute
                };

                workerNamespace.CreateTopic(td);
            }

            topicClient = TopicClient.CreateFromConnectionString(workerConn, ServiceBusPathNames.ServiceBusUpdateTopic);

            // Frontend Notification Queue
            var nm = NamespaceManager.CreateFromConnectionString(workerConn);
            if (!nm.QueueExists(ServiceBusPathNames.ServiceBusUpdateQueue))
            {
                nm.CreateQueue(ServiceBusPathNames.ServiceBusUpdateQueue);
            }

            frontendClient = QueueClient.CreateFromConnectionString(workerConn, ServiceBusPathNames.ServiceBusUpdateQueue);
        }
开发者ID:baiyunping333,项目名称:BlazeDSP,代码行数:49,代码来源:SerialBusConfig.cs


示例14: CreateTopc

        public void CreateTopc()
        {
            var topicDesc = new TopicDescription(TopicName)
                {
                    MaxSizeInMegabytes = 5120,
                    DefaultMessageTimeToLive = new TimeSpan(0, 20, 0)
                };

            var namespaceManager = NamespaceManager.CreateFromConnectionString(ConnectionString);

            if (!namespaceManager.TopicExists(TopicName))
            {
                namespaceManager.CreateTopic(topicDesc);
            }
        }
开发者ID:GAllenD,项目名称:LearnAzureServiceBus,代码行数:15,代码来源:Publisher.cs


示例15: AzureServiceBusEndpointAddress

        AzureServiceBusEndpointAddress([NotNull] Data data,
            AddressType addressType)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            _data = data;

            _tp = TokenProvider.CreateSharedSecretTokenProvider(_data.UsernameIssuer,
                _data.PasswordSharedSecret);

            Uri sbUri = ServiceBusEnvironment.CreateServiceUri("sb", _data.Namespace, string.Empty);

            var mfs = new MessagingFactorySettings
                {
                    TokenProvider = _tp,
                    NetMessagingTransportSettings =
                        {
                            // todo: configuration setting
                            BatchFlushInterval = 50.Milliseconds()
                        },
                    OperationTimeout = 3.Seconds()
                };
            _mff = () => MessagingFactory.Create(sbUri, mfs);

            _nm = new NamespaceManager(sbUri, _tp);

            string suffix = "";
            if (addressType == AddressType.Queue)
                _queueDescription = new QueueDescriptionImpl(data.QueueOrTopicName);
            else
            {
                _topicDescription = new TopicDescriptionImpl(data.QueueOrTopicName);
                suffix = "?topic=true";
            }

            _rebuiltUri = new Uri(string.Format("azure-sb://{0}:{1}@{2}/{3}{4}",
                data.UsernameIssuer,
                data.PasswordSharedSecret,
                data.Namespace,
                data.QueueOrTopicName,
                suffix));

            _friendlyUri = new Uri(string.Format("azure-sb://{0}/{1}{2}",
                data.Namespace,
                data.QueueOrTopicName,
                suffix));
        }
开发者ID:jglozano,项目名称:MassTransit-AzureServiceBus,代码行数:48,代码来源:AzureServiceBusEndpointAddress.cs


示例16: CreateTopic

        public void CreateTopic()
        {
            var topic = new TopicDescription(_topicName);

            AuthorizationRule user1Rule = ServiceBusHelper.CreateAccessRule(TestUsers.User1.UserName, new List<AccessRights> { AccessRights.Listen, AccessRights.Send });
            topic.Authorization.Add(user1Rule);

            AuthorizationRule user2Rule = ServiceBusHelper.CreateAccessRule(TestUsers.User2.UserName, new List<AccessRights> { AccessRights.Listen });
            topic.Authorization.Add(user2Rule);

            AuthorizationRule user3Rule = ServiceBusHelper.CreateAccessRule(TestUsers.User3.UserName, new List<AccessRights> { AccessRights.Send });
            topic.Authorization.Add(user3Rule);

            NamespaceManager nsManager = ServiceBusHelper.GetNamespaceManager();
            nsManager.CreateTopic(topic);
        }
开发者ID:nordvall,项目名称:letterbox,代码行数:16,代码来源:TopicClientTests.cs


示例17: Bus

        public Bus() {
            connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            // Configure Topic Settings
            var td = new TopicDescription(topicName);
            td.MaxSizeInMegabytes = 5120;
            td.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);

            if (!namespaceManager.TopicExists(topicName)) {
                namespaceManager.CreateTopic(topicName);
            }

            factory = MessagingFactory.CreateFromConnectionString(connectionString);
            sender = factory.CreateMessageSender(topicName);
        }
开发者ID:anlcan,项目名称:coapp.org,代码行数:16,代码来源:Bus.cs


示例18: CoAppRepositoryDaemonMain

        public CoAppRepositoryDaemonMain() {
            connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            // Configure Topic Settings
            var td1 = new TopicDescription(regenSiteTopic) {
                MaxSizeInMegabytes = 5120,
                DefaultMessageTimeToLive = new TimeSpan(0, 1, 0)
            };

            if (!namespaceManager.TopicExists(regenSiteTopic)) {
                namespaceManager.CreateTopic(regenSiteTopic);
            }

            factory = MessagingFactory.CreateFromConnectionString(connectionString);
            _running = true;
        }
开发者ID:Gocy015,项目名称:coapp.org,代码行数:17,代码来源:CoAppRepositoryDaemonMain.cs


示例19: button1_Click

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // Configure Topic Settings.
            TopicDescription td = new TopicDescription("TestTopic2");
            td.MaxSizeInMegabytes = 5120;
            td.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0);

            string connectionString = new Properties.Settings().ConnectionString;

            var namespaceManager =
                NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.TopicExists("TestTopic2"))
            {
                namespaceManager.CreateTopic(td);
            }
        }
开发者ID:kiyo7447,项目名称:AzureSample,代码行数:17,代码来源:MainWindow.xaml.cs


示例20: ensureTopicExists

        private static void ensureTopicExists(string connectionString, string serviceBusTopic)
        {
            lock (createLock)
            {
                var nsMgr = NamespaceManager.CreateFromConnectionString(connectionString);
                if (nsMgr.TopicExists(serviceBusTopic))
                    return;

                var definition = new TopicDescription(serviceBusTopic)
                                     {
                                         MaxSizeInMegabytes = 1024,
                                         DefaultMessageTimeToLive = TimeSpan.FromDays(365)
                                     };

                nsMgr.CreateTopic(definition);
            }
        }
开发者ID:AndyHitchman,项目名称:BlastTrack,代码行数:17,代码来源:MessageTopicPublisher.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TopicModel类代码示例发布时间:2022-05-24
下一篇:
C# Topic类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap