Esempio n. 1
0
        SubscriptionEndpointSettings(TopicDescription topicDescription, SubscriptionConfigurator configurator)
            : base(configurator)
        {
            _topicDescription         = topicDescription;
            _subscriptionConfigurator = configurator;

            Name = Path = EntityNameFormatter.FormatSubscriptionPath(_subscriptionConfigurator.TopicPath, _subscriptionConfigurator.SubscriptionName);
        }
Esempio n. 2
0
        SubscriptionEndpointSettings(TopicDescription topicDescription, SubscriptionConfigurator configurator)
            : base(configurator)
        {
            _topicDescription         = topicDescription;
            _subscriptionConfigurator = configurator;

            Name = Path = EntityNameFormatter.FormatSubscriptionPath(_subscriptionConfigurator.TopicPath, _subscriptionConfigurator.SubscriptionName);

            MaxConcurrentCalls = Math.Max(Environment.ProcessorCount, 8);
            PrefetchCount      = Math.Max(MaxConcurrentCalls, 32);
        }
Esempio n. 3
0
        public SubscriptionEndpointSettings(TopicDescription topicDescription, string subscriptionName)
            : this(topicDescription, new SubscriptionConfigurator(topicDescription.Path, subscriptionName))
        {
            _topicDescription         = topicDescription;
            _subscriptionConfigurator = new SubscriptionConfigurator(topicDescription.Path, subscriptionName);

            Name = Path = EntityNameFormatter.FormatSubscriptionPath(_subscriptionConfigurator.TopicPath, _subscriptionConfigurator.SubscriptionName);

            MaxConcurrentCalls = Math.Max(Environment.ProcessorCount, 8);
            PrefetchCount      = Math.Max(MaxConcurrentCalls, 32);
        }
Esempio n. 4
0
        SubscriptionEndpointSettings(TopicDescription topicDescription, SubscriptionConfigurator configurator)
            : base(configurator)
        {
            _topicDescription         = topicDescription;
            _subscriptionConfigurator = configurator;

            Name = Path = EntityNameFormatter.FormatSubscriptionPath(_subscriptionConfigurator.TopicPath, _subscriptionConfigurator.SubscriptionName);

            MaxConcurrentCalls = Defaults.MaxConcurrentCalls;
            PrefetchCount      = Defaults.PrefetchCount;
        }
Esempio n. 5
0
        public SubscriptionEndpointSettings(TopicDescription topicDescription, string subscriptionName)
            : this(topicDescription, new SubscriptionConfigurator(topicDescription.Path, subscriptionName))
        {
            _topicDescription         = topicDescription;
            _subscriptionConfigurator = new SubscriptionConfigurator(topicDescription.Path, subscriptionName);

            Name = Path = EntityNameFormatter.FormatSubscriptionPath(_subscriptionConfigurator.TopicPath, _subscriptionConfigurator.SubscriptionName);

            MaxConcurrentCalls = Defaults.MaxConcurrentCalls;
            PrefetchCount      = Defaults.PrefetchCount;
        }
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ParameterInfo parameter = context.Parameter;
            var           attribute = TypeUtility.GetResolvedAttribute <ServiceBusTriggerAttribute>(parameter);

            if (attribute == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            string     queueName        = null;
            string     topicName        = null;
            string     subscriptionName = null;
            string     entityPath       = null;
            EntityType entityType;

            if (attribute.QueueName != null)
            {
                queueName  = Resolve(attribute.QueueName);
                entityPath = queueName;
                entityType = EntityType.Queue;
            }
            else
            {
                topicName        = Resolve(attribute.TopicName);
                subscriptionName = Resolve(attribute.SubscriptionName);
                entityPath       = EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName);
                entityType       = EntityType.Topic;
            }

            attribute.Connection = Resolve(attribute.Connection);
            ServiceBusAccount account = new ServiceBusAccount(_options, _configuration, attribute);

            Func <ListenerFactoryContext, bool, Task <IListener> > createListener =
                (factoryContext, singleDispatch) =>
            {
                IListener listener = new ServiceBusListener(factoryContext.Descriptor.Id, entityType, entityPath, attribute.IsSessionsEnabled, factoryContext.Executor, _options, account, _messagingProvider, _loggerFactory, singleDispatch);
                return(Task.FromResult(listener));
            };

#pragma warning disable 618
            ITriggerBinding binding = BindingFactory.GetTriggerBinding(new ServiceBusTriggerBindingStrategy(), parameter, _converterManager, createListener);
#pragma warning restore 618

            return(Task.FromResult <ITriggerBinding>(binding));
        }
        public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            ParameterInfo parameter = context.Parameter;
            var           attribute = TypeUtility.GetResolvedAttribute <ServiceBusTriggerAttribute>(parameter);

            if (attribute == null)
            {
                return(Task.FromResult <ITriggerBinding>(null));
            }

            attribute.Connection = _nameResolver.ResolveWholeString(attribute.Connection);
            string entityPath;
            ServiceBusEntityType serviceBusEntityType;

            if (attribute.QueueName != null)
            {
                var queueName = _nameResolver.ResolveWholeString(attribute.QueueName);
                entityPath           = queueName;
                serviceBusEntityType = ServiceBusEntityType.Queue;
            }
            else
            {
                var topicName        = _nameResolver.ResolveWholeString(attribute.TopicName);
                var subscriptionName = _nameResolver.ResolveWholeString(attribute.SubscriptionName);
                entityPath           = EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName);
                serviceBusEntityType = ServiceBusEntityType.Topic;
            }

            Func <ListenerFactoryContext, bool, Task <IListener> > createListener =
                (factoryContext, singleDispatch) =>
            {
                var       autoCompleteMessagesOptionEvaluatedValue = GetAutoCompleteMessagesOptionToUse(attribute, factoryContext.Descriptor.ShortName);
                IListener listener = new ServiceBusListener(factoryContext.Descriptor.Id, serviceBusEntityType, entityPath, attribute.IsSessionsEnabled, autoCompleteMessagesOptionEvaluatedValue, factoryContext.Executor, _options, attribute.Connection, _messagingProvider, _loggerFactory, singleDispatch, _clientFactory, _concurrencyManager);

                return(Task.FromResult(listener));
            };

#pragma warning disable 618
            ITriggerBinding binding = BindingFactory.GetTriggerBinding(new ServiceBusTriggerBindingStrategy(), parameter, _converterManager, createListener);
#pragma warning restore 618

            return(Task.FromResult <ITriggerBinding>(binding));
        }