Пример #1
0
        public async Task UpdateSubscriptionsAsync(IBus bus, IEnumerable <SubscriptionsForType> subscriptionsForTypes)
        {
            var subscriptions = subscriptionsForTypes as SubscriptionsForType[] ?? subscriptionsForTypes.ToArray();

            if (subscriptions.Length == 0)
            {
                return;
            }

            var command = new UpdatePeerSubscriptionsForTypesCommand(_self.Id, _timestampProvider.NextUtcTimestamp(), subscriptions);

            foreach (var directoryPeer in GetDirectoryPeers())
            {
                try
                {
                    await bus.Send(command, directoryPeer).WithTimeoutAsync(_configuration.RegistrationTimeout).ConfigureAwait(false);

                    return;
                }
                catch (TimeoutException ex)
                {
                    _logger.Error(ex);
                }
            }

            throw new TimeoutException("Unable to update peer subscriptions on directory");
        }
Пример #2
0
        public void UpdateSubscriptions(IBus bus, IEnumerable <SubscriptionsForType> subscriptionsForTypes)
        {
            var subscriptions = subscriptionsForTypes as SubscriptionsForType[] ?? subscriptionsForTypes.ToArray();

            if (subscriptions.Length == 0)
            {
                return;
            }

            var command        = new UpdatePeerSubscriptionsForTypesCommand(_self.Id, _timestampProvider.NextUtcTimestamp(), subscriptions);
            var directoryPeers = GetDirectoryPeers();

            if (!directoryPeers.Any(peer => bus.Send(command, peer).Wait(5.Seconds())))
            {
                throw new TimeoutException("Unable to update peer subscriptions on directory");
            }
        }