Beispiel #1
0
        public void Scatter <TRequest, TResponse>(string topic, Envelope <TRequest> envelope, IGatherReceiver <TResponse> scatter)
        {
            Assert.ArgumentNotNull(envelope, nameof(envelope));
            Assert.ArgumentNotNull(scatter, nameof(scatter));

            var topicEnvelope = envelope.RedirectToTopic(topic);
            var participants  = _store.GetParticipants <TRequest, TResponse>(topic);

            _log.Debug("Scattering RequestType={0} ResponseType={1} Topic={2}", typeof(TRequest).FullName, typeof(TResponse).FullName, topic);
            foreach (var participant in participants)
            {
                try
                {
                    scatter.AddParticipant(participant.Id);
                    participant.Scatter(topicEnvelope, scatter);
                }
                catch (Exception e)
                {
                    _log.Error($"Unhandled scatter request Type={typeof(TRequest).FullName}, {typeof(TResponse).FullName} Topic={topic}: {e.Message}\n{e.StackTrace}");
                }
                if (participant.ShouldStopParticipating)
                {
                    _store.RemoveParticipant(topic, participant);
                }
            }
        }
 public void AddParticipant(Guid participantId)
 {
     _inner.AddParticipant(participantId);
 }