示例#1
0
        public void Subscribe(string subscriptionName, Action <ISubscriptionConfigurator> configure = null)
        {
            if (string.IsNullOrWhiteSpace(subscriptionName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(subscriptionName));
            }

            if (!IsBindableMessageType)
            {
                _specifications.Add(new InvalidServiceBusConsumeTopologySpecification(TypeMetadataCache <TMessage> .ShortName, "Is not a bindable message type"));
                return;
            }

            var topicDescription = _publishTopology.TopicDescription;

            var subscriptionConfigurator = new SubscriptionConfigurator(topicDescription.Path, subscriptionName);

            configure?.Invoke(subscriptionConfigurator);

            var specification = new SubscriptionConsumeTopologySpecification(topicDescription, subscriptionConfigurator.GetSubscriptionDescription(), subscriptionConfigurator.Rule,
                                                                             subscriptionConfigurator.Filter);

            _specifications.Add(specification);
        }
示例#2
0
        public void Subscribe(string topicName, string subscriptionName, Action <ISubscriptionConfigurator> callback = null)
        {
            if (string.IsNullOrWhiteSpace(topicName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(topicName));
            }

            if (string.IsNullOrWhiteSpace(subscriptionName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(subscriptionName));
            }

            subscriptionName = _publishTopology.FormatSubscriptionName(subscriptionName);

            var topicDescription = Defaults.CreateTopicDescription(topicName);

            var subscriptionConfigurator = new SubscriptionConfigurator(topicDescription.Path, subscriptionName);

            callback?.Invoke(subscriptionConfigurator);

            var specification = new SubscriptionConsumeTopologySpecification(topicDescription, subscriptionConfigurator.GetSubscriptionDescription(),
                                                                             subscriptionConfigurator.Rule,
                                                                             subscriptionConfigurator.Filter);

            _specifications.Add(specification);
        }
示例#3
0
        public void Subscribe(string subscriptionName, Action <ISubscriptionConfigurator> configure = null)
        {
            if (!IsBindableMessageType)
            {
                _specifications.Add(new InvalidServiceBusConsumeTopologySpecification(TypeMetadataCache <TMessage> .ShortName, "Is not a bindable message type"));
                return;
            }

            var topicDescription = _publishTopology.TopicDescription;

            var subscriptionConfigurator = new SubscriptionConfigurator(topicDescription.Path, subscriptionName);

            configure?.Invoke(subscriptionConfigurator);

            var specification = new SubscriptionConsumeTopologySpecification(topicDescription, subscriptionConfigurator.GetSubscriptionDescription());

            _specifications.Add(specification);
        }