public void ExecuteCallback(CompletionAcknowledgementMessage message)
 {
     if (message.ProcessingSuccessful == false)
         throw new FailedMessageProcessingException(message);
     _callbacks(message);
     _waitForCompletionHandle.Set();
 }
        public void should_serialize_deserialize()
        {
            var message = new CompletionAcknowledgementMessage(Guid.NewGuid(), "type", true, new ZmqEndpoint("toto"));

            var data = _serializer.Serialize(message);
            var deserialized = _serializer.Deserialize(data);

            Assert.AreEqual(message.Endpoint, deserialized.Endpoint);
            Assert.AreEqual(message.MessageId, deserialized.MessageId);
            Assert.AreEqual(message.MessageType, deserialized.MessageType);
            Assert.AreEqual(message.ProcessingSuccessful, deserialized.ProcessingSuccessful);
        }
        public void should_invoke_proper_callback_when_receiving_message()
        {
            var messageId = Guid.NewGuid();
            var completionAcknowledgementMessage = new CompletionAcknowledgementMessage(messageId, "test", true, null);
            bool success = false;
            var completionCallbackMock = new Mock<ICompletionCallback>();
            completionCallbackMock.Setup(x => x.ExecuteCallback(completionAcknowledgementMessage)).Callback(() => success = true);
            _callbackManagerMock.Setup(x => x.GetCallback(messageId)).Returns(completionCallbackMock.Object);

            _handler.Handle(completionAcknowledgementMessage);

            _callbackManagerMock.Verify(x => x.GetCallback(It.IsAny<Guid>()), Times.Once());
            _callbackManagerMock.Verify(x => x.RemoveCallback(messageId), Times.Once());
            Assert.IsTrue(success);
        }
Пример #4
0
        public void Acknowledge(Guid messageId, string messageType, bool processSuccessful, PeerId originatingPeer, IEndpoint endpoint)
        {
            var acknowledgementMessage = new CompletionAcknowledgementMessage(messageId, messageType, processSuccessful, endpoint);
            var sequence = _ringBuffer.Next();
            var data = _ringBuffer[sequence];

            data.MessageTargetHandlerData.Message = acknowledgementMessage;
            data.MessageTargetHandlerData.TargetPeer = originatingPeer;
            data.MessageTargetHandlerData.IsAcknowledgement = true;
            data.MessageTargetHandlerData.Callback = null;
            data.NetworkSenderData.Command = null;
            data.NetworkSenderData.WireMessages = new List<WireSendingMessage>(2);
            //            data.NetworkSenderData = new NetworkSenderData();

            _ringBuffer.Publish(sequence);
        }
 public FailedMessageProcessingException(CompletionAcknowledgementMessage message)
     : base(string.Format("Message processing failed on message {0}", message.MessageId))
 {
 }