public TopologySectionInternal DetermineResourcesToUnsubscribeFrom(Type eventtype)
        {
            if (!subscriptions.TryRemove(eventtype, out var result))
            {
                result = new TopologySectionInternal
                {
                    Entities   = new List <SubscriptionInfoInternal>(),
                    Namespaces = new List <RuntimeNamespaceInfo>()
                };
            }

            return(result);
        }
コード例 #2
0
        public void Start(TopologySectionInternal topologySection, int maximumConcurrency)
        {
            maxConcurrency = maximumConcurrency;
            topology       = topologySection;

            StartNotifiersFor(topology.Entities);

            running = true;

            while (pendingStartOperations.TryTake(out var operation))
            {
                operation();
            }
        }
コード例 #3
0
        public void Start(TopologySectionInternal topologySection, int maximumConcurrency)
        {
            maxConcurrency = maximumConcurrency;
            topology       = topologySection;

            StartNotifiersFor(topology.Entities);

            foreach (var operation in pendingStartOperations)
            {
                operation();
            }

            pendingStartOperations = new List <Action>();
            running = true;
        }
コード例 #4
0
        public async Task Create(TopologySectionInternal topology)
        {
            if (!await hasManageRights.Value.ConfigureAwait(false))
            {
                logger.Info($"Configured to create topology, but have no manage rights for the following namespace(s): {namespacesWithoutManageRightsJoined}. Execution will continue and assume the topology is already created.");
                return;
            }

            var queues        = topology.Entities.Where(e => e.Type == EntityType.Queue).ToList();
            var topics        = topology.Entities.Where(e => e.Type == EntityType.Topic).ToList();
            var subscriptions = topology.Entities.Where(e => e.Type == EntityType.Subscription).ToList();

            if (queues.Any())
            {
                foreach (var queue in queues)
                {
                    await queuesCreator.Create(queue.Path, namespaces.Get(queue.Namespace.Alias)).ConfigureAwait(false);
                }
            }

            if (topics.Any())
            {
                foreach (var topic in topics)
                {
                    await topicsCreator.Create(topic.Path, namespaces.Get(topic.Namespace.Alias)).ConfigureAwait(false);
                }
            }

            if (subscriptions.Any())
            {
                foreach (var subscription in subscriptions)
                {
                    var topic     = subscription.RelationShips.First(r => r.Type == EntityRelationShipTypeInternal.Subscription);
                    var forwardTo = subscription.RelationShips.FirstOrDefault(r => r.Type == EntityRelationShipTypeInternal.Forward);
                    var sqlFilter = (subscription as SubscriptionInfoInternal)?.BrokerSideFilter.Serialize();
                    var metadata  = (subscription as SubscriptionInfoInternal)?.Metadata ?? new SubscriptionMetadataInternal();
                    await subscriptionsCreator.Create(topic.Target.Path, subscription.Path, metadata, sqlFilter, namespaces.Get(subscription.Namespace.Alias), forwardTo?.Target.Path).ConfigureAwait(false);
                }
            }
        }
コード例 #5
0
        public async Task TearDown(TopologySectionInternal topologySection)
        {
            var subscriptions = topologySection.Entities.Where(e => e.Type == EntityType.Subscription).ToList();

            if (subscriptions.Any())
            {
                foreach (var subscription in subscriptions)
                {
                    var topic     = subscription.RelationShips.First(r => r.Type == EntityRelationShipTypeInternal.Subscription);
                    var forwardTo = subscription.RelationShips.FirstOrDefault(r => r.Type == EntityRelationShipTypeInternal.Forward);
                    var sqlFilter = (subscription as SubscriptionInfoInternal)?.BrokerSideFilter.Serialize();
                    var metadata  = (subscription as SubscriptionInfoInternal)?.Metadata ?? new SubscriptionMetadataInternal();


                    await subscriptionsCreator.DeleteSubscription(topicPath : topic.Target.Path,
                                                                  subscriptionName : subscription.Path,
                                                                  metadata : metadata,
                                                                  sqlFilter : sqlFilter,
                                                                  namespaceManager : namespaces.Get(subscription.Namespace.Alias),
                                                                  forwardTo : forwardTo?.Target.Path).ConfigureAwait(false);
                }
            }
        }