コード例 #1
0
ファイル: EnvelopeSent.cs プロジェクト: kingreatwill/fubumvc
        public EnvelopeSent(EnvelopeToken envelope, ChannelNode node)
        {
            Envelope = envelope;

            Uri = node.Uri;
            Key = node.Key;
        }
コード例 #2
0
        public void handle_envelope_sent_then_message_failed_for_multiple_messages_to_the_same_node()
        {
            MessageHistory.ClearHistory();

            var envelope1 = new EnvelopeToken();
            var envelope2 = new EnvelopeToken();
            var node1 = new StubChannelNode();

            MessageHistory.Record(new EnvelopeSent(envelope1, node1));
            MessageHistory.Record(new EnvelopeSent(envelope2, node1));

            MessageHistory.Outstanding().Count().ShouldBe(2);

            envelope1.Destination = node1.Uri;
            MessageHistory.Record(new MessageFailed
            {
                Envelope = envelope1
            });

            MessageHistory.Outstanding().Count().ShouldBe(1);

            envelope2.Destination = node1.Uri;
            MessageHistory.Record(new MessageFailed
            {
                Envelope = envelope2
            });

            MessageHistory.Outstanding().Any().ShouldBeFalse();
        }
コード例 #3
0
        public void SetUp()
        {
            theToken = ObjectMother.EnvelopeWithMessage().ToToken();
            theToken.ParentId = Guid.NewGuid().ToString();
            theToken.Headers["A"] = "1";
            theToken.Headers["B"] = "2";

            theRecord = new MessageRecord(theToken);
        }
コード例 #4
0
        public void Send(byte[] data, IHeaders headers)
        {
            var envelope = new EnvelopeToken
            {
                Data = data,
                Headers = headers
            };

            _queue.Enqueue(envelope);
        }
コード例 #5
0
ファイル: InMemoryQueue.cs プロジェクト: kingreatwill/fubumvc
        public void Enqueue(EnvelopeToken envelope)
        {
            using (var stream = new MemoryStream())
            {
                _formatter.Serialize(stream, envelope);

                stream.Position = 0;
                var bytes = stream.ReadAllBytes();

                _queue.Add(bytes);
            }
        }
コード例 #6
0
ファイル: MessageRecord.cs プロジェクト: kingreatwill/fubumvc
        public MessageRecord(EnvelopeToken envelope)
        {
            Id = envelope.CorrelationId;
            ParentId = envelope.ParentId;
            if (envelope.Message != null)
            {
                _messageType = envelope.Message.GetType();
                Type = _messageType.FullName;
            }

            Headers = envelope.Headers.Keys().Select(x => "{0}={1}".ToFormat(x, envelope.Headers[x])).Join(";");
        }
コード例 #7
0
ファイル: InMemoryQueue.cs プロジェクト: kingreatwill/fubumvc
 public InMemoryCallback(InMemoryQueue parent, EnvelopeToken token)
 {
     _parent = parent;
     _token = token;
 }
コード例 #8
0
ファイル: EnvelopeToken.cs プロジェクト: kingreatwill/fubumvc
 protected bool Equals(EnvelopeToken other)
 {
     return Equals(Data, other.Data) && Equals(Headers, other.Headers);
 }
コード例 #9
0
        public void handle_envelope_sent_then_message_successful_tracking_for_the_same_message_to_multiple_nodes()
        {
            MessageHistory.ClearHistory();

            var envelope1 = new EnvelopeToken();
            var node1 = new StubChannelNode();
            var node2 = new StubChannelNode();

            MessageHistory.Record(new EnvelopeSent(envelope1, node1).ToMessageTrack());
            MessageHistory.Record(new EnvelopeSent(envelope1, node2).ToMessageTrack());

            MessageHistory.Outstanding().Count().ShouldBe(2);

            envelope1.Destination = node1.Uri;

            MessageHistory.Record(new MessageSuccessful
            {
                Envelope = envelope1
            }.ToMessageTrack());

            MessageHistory.Outstanding().Count().ShouldBe(1);

            envelope1.Destination = node2.Uri;

            MessageHistory.Record(new MessageSuccessful
            {
                Envelope = envelope1
            }.ToMessageTrack());

            MessageHistory.Outstanding().Any().ShouldBeFalse();
        }
コード例 #10
0
        public void SetUp()
        {
            theEvents = MockRepository.GenerateMock<IEventAggregator>();

            theListener = new ReplyListener<Message1>(theEvents, correlationId, 10.Minutes());

            theMessage = new Message1();

            var envelope = new EnvelopeToken
            {
                Message = theMessage
            };

            envelope.Headers[Envelope.ResponseIdKey] = correlationId;

            theListener.Handle(new EnvelopeReceived
            {
                Envelope = envelope
            });
        }
コード例 #11
0
        public void SetUp()
        {
            theEvents = MockRepository.GenerateMock<IEventAggregator>();

            theListener = new ReplyListener<Message1>(theEvents, correlationId, 10.Minutes());

            var envelope = new EnvelopeToken
            {
                Message = new FailureAcknowledgement
                {
                    CorrelationId = correlationId,
                    Message = "No soup for you!"
                }
            };

            envelope.Headers[Envelope.ResponseIdKey] = correlationId;

            theListener.Handle(new EnvelopeReceived
            {
                Envelope = envelope
            });
        }
コード例 #12
0
 protected bool Equals(EnvelopeToken other)
 {
     return(Equals(Data, other.Data) && Equals(Headers, other.Headers));
 }
コード例 #13
0
 public static void AddToDelayedQueue(EnvelopeToken envelope)
 {
     _delayedLock.Write(() => {
         _delayed.Add(envelope);
     });
 }
コード例 #14
0
        public void handle_envelope_sent_then_message_successful_tracking_for_the_same_message_to_multiple_nodes()
        {
            MessageHistory.StartListening();

            var envelope1 = new EnvelopeToken();
            var node1 = new StubChannelNode();
            var node2 = new StubChannelNode();

            var messageWatcher = new MessageWatcher();

            messageWatcher.Handle(new EnvelopeSent(envelope1, node1));
            messageWatcher.Handle(new EnvelopeSent(envelope1, node2));

            MessageHistory.Outstanding().Count().ShouldBe(2);

            envelope1.Destination = node1.Uri;
            messageWatcher.Handle(new MessageSuccessful
            {
                Envelope = envelope1
            });

            MessageHistory.Outstanding().Count().ShouldBe(1);

            envelope1.Destination = node2.Uri;
            messageWatcher.Handle(new MessageSuccessful
            {
                Envelope = envelope1
            });

            MessageHistory.Outstanding().Any().ShouldBeFalse();
        }
コード例 #15
0
ファイル: ReplyListener.cs プロジェクト: zzekikaya/fubumvc
 public bool Matches(EnvelopeToken envelope)
 {
     return(envelope.Message is T && envelope.ResponseId == _originalId);
 }