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


C# TopicDescription类代码示例

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


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


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