Exemplo n.º 1
0
        public void Handle(ReaderSubscriptionManagement.Unsubscribe message)
        {
            if (!_pausedSubscriptions.Contains(message.SubscriptionId))
            {
                Handle(new ReaderSubscriptionManagement.Pause(message.SubscriptionId));
            }
            var eventReaderId = _subscriptionEventReaders[message.SubscriptionId];

            if (eventReaderId != Guid.Empty)
            {
                //TODO: test it
                _eventReaders[eventReaderId].Dispose();
                _eventReaders.Remove(eventReaderId);
                _eventReaderSubscriptions.Remove(eventReaderId);
                _publisher.Publish(
                    new EventReaderSubscriptionMessage.ReaderAssignedReader(message.SubscriptionId, Guid.Empty));
//                _logger.Trace(
//                    "The '{0}' subscription has unsubscribed (reader: {1})", message.SubscriptionId,
//                    eventReaderId);
            }

            _pausedSubscriptions.Remove(message.SubscriptionId);
            _subscriptionEventReaders.Remove(message.SubscriptionId);
            _subscriptions.Remove(message.SubscriptionId);
        }
Exemplo n.º 2
0
        public void Handle(ReaderSubscriptionManagement.Unsubscribe message)
        {
            if (!_pausedSubscriptions.Contains(message.SubscriptionId))
            {
                Handle(new ReaderSubscriptionManagement.Pause(message.SubscriptionId));
            }
            var eventReaderId = Guid.Empty;

            _subscriptionEventReaders.TryGetValue(message.SubscriptionId, out eventReaderId);
            if (eventReaderId != Guid.Empty)
            {
                _eventReaders[eventReaderId].Dispose();
                _eventReaders.Remove(eventReaderId);
                _eventReaderSubscriptions.Remove(eventReaderId);
                _publisher.Publish(
                    new EventReaderSubscriptionMessage.ReaderAssignedReader(message.SubscriptionId, Guid.Empty));
            }

            _pausedSubscriptions.Remove(message.SubscriptionId);
            _subscriptionEventReaders.Remove(message.SubscriptionId);
            _subscriptions.Remove(message.SubscriptionId);
        }