Esempio n. 1
0
        private void RetryPendingSubscriptions(IPEndPoint ep, Type type = null)
        {
            _log.DebugFormat("Retrying to find publishers for pending subscriptions {0}", type == null ? string.Empty : string.Format("of type {0}", type.Name));
            try
            {
                var cache = type == null?SubscriptionCache.ToArray() : SubscriptionCache.Where(c => c.Value == type).ToArray();

                foreach (var sub in cache)
                {
                    if (type != null && sub.Value != type)
                    {
                        return;
                    }

                    Message subscription = new Message(sub.Key)
                    {
                        Type = MessageType.Subscribe,
                        Data = Serializer.Serialize(sub.Value)
                    };

                    _log.DebugFormat("Resending subscription request message {0}", subscription.Id);
                    SenderBase.SendAsync(subscription, ep);
                }
            }
            catch (Exception ex)
            {
                _log.ErrorFormat("Could not retry pending subscriptions: {0}\n{1}", ex.Message, ex.StackTrace);
                return;
            }
        }