Пример #1
0
        /// <summary>
        /// Creates a new topic
        /// </summary>
        /// <param name="configure">The builder.</param>
        /// <returns>Client to access the created topic</returns>
        public async Task <ITopicClient> CreateTopicAsync(Action <ServiceBusTopicBuilder> configure)
        {
            var builder = ServiceBusTopicBuilder.New();

            configure(builder);
            ServiceBusTopicModel topic = builder.Build();

            await CreateTopicAsync(topic);

            _serviceBusModel.Topics.Add(topic);
            return(GetTopicClient(topic.Name));
        }
Пример #2
0
        private string GetTopic(string name)
        {
            ServiceBusTopicModel topic = _serviceBusModel.Topics
                                         .FirstOrDefault(x => x.Name.Equals(name,
                                                                            StringComparison.InvariantCultureIgnoreCase));

            if (topic == null)
            {
                throw new InvalidOperationException($"No topic found with name: {name}");
            }

            return(topic.CreatedName);
        }
Пример #3
0
        private async Task <string> CreateTopicAsync(ServiceBusTopicModel topic)
        {
            if (_serviceBusModel.ProvisioningMode == ServiceBusProvisioningMode.UseExisting)
            {
                topic.CreatedName = $"{topic.Name}_{DateTime.UtcNow.Ticks}";
            }
            else
            {
                topic.CreatedName = topic.Name;
            }
            await _serviceBusManager.CreateTopic(topic);

            return(topic.CreatedName);
        }
Пример #4
0
        internal async Task CreateTopic(ServiceBusTopicModel model)
        {
            await EnsureAuthenticatedAsync();

            Trace.WriteLine($"Create topic: {model.CreatedName}");
            var pars = new SBTopic()
            {
                AutoDeleteOnIdle = TimeSpan.FromMinutes(30)
            };

            SBTopic topic = _client.Topics.CreateOrUpdate(
                _identifier.ResourceGroupName,
                _identifier.Name,
                model.CreatedName,
                pars);

            foreach (ServiceBusSubscriptionModel sub in model.Subscriptions)
            {
                await CreateSubscription(topic.Name, sub);
            }
        }
Пример #5
0
 private ServiceBusTopicBuilder(string topicName)
 {
     _topic = new ServiceBusTopicModel(topicName);
 }
Пример #6
0
 private ServiceBusTopicBuilder()
 {
     _topic = new ServiceBusTopicModel();
 }