Beispiel #1
0
        public void Complete(Envelope envelope, string activity, Exception ex = null)
        {
            var key         = MessageTrack.ToKey(envelope, activity);
            var messageType = envelope.Message?.GetType();

            lock (_lock)
            {
                if (_outstanding.ContainsKey(key))
                {
                    var track = _outstanding[key];
                    _outstanding.Remove(key);

                    track.Finish(envelope, ex);

                    _completed.Add(track);

                    processCompletion();
                }
                else if (messageType != null && _backgroundWaiters.ContainsKey(messageType))
                {
                    var waiter = _backgroundWaiters[messageType];
                    _backgroundWaiters.Remove(messageType);
                    var track = new MessageTrack(envelope, activity);
                    track.Finish(envelope, ex);
                    waiter.SetResult(track);
                }
            }
        }
Beispiel #2
0
        public void Start(Envelope envelope, string activity)
        {
            var track = new MessageTrack(envelope, activity);

            lock (_lock)
            {
                if (_outstanding.ContainsKey(track.Key))
                {
                    _outstanding[track.Key] = track;
                }
                else
                {
                    _outstanding.Add(track.Key, track);
                }
            }
        }