public EnvelopeSent(EnvelopeToken envelope, ChannelNode node) { Envelope = envelope; Uri = node.Uri; Key = node.Key; }
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(); }
public void SetUp() { theToken = ObjectMother.EnvelopeWithMessage().ToToken(); theToken.ParentId = Guid.NewGuid().ToString(); theToken.Headers["A"] = "1"; theToken.Headers["B"] = "2"; theRecord = new MessageRecord(theToken); }
public void Send(byte[] data, IHeaders headers) { var envelope = new EnvelopeToken { Data = data, Headers = headers }; _queue.Enqueue(envelope); }
public void Enqueue(EnvelopeToken envelope) { using (var stream = new MemoryStream()) { _formatter.Serialize(stream, envelope); stream.Position = 0; var bytes = stream.ReadAllBytes(); _queue.Add(bytes); } }
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(";"); }
public InMemoryCallback(InMemoryQueue parent, EnvelopeToken token) { _parent = parent; _token = token; }
protected bool Equals(EnvelopeToken other) { return Equals(Data, other.Data) && Equals(Headers, other.Headers); }
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(); }
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 }); }
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 }); }
protected bool Equals(EnvelopeToken other) { return(Equals(Data, other.Data) && Equals(Headers, other.Headers)); }
public static void AddToDelayedQueue(EnvelopeToken envelope) { _delayedLock.Write(() => { _delayed.Add(envelope); }); }
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(); }
public bool Matches(EnvelopeToken envelope) { return(envelope.Message is T && envelope.ResponseId == _originalId); }