public void should_send_MessageProcessingFailed_if_unable_to_deserialize_message()
            {
                SetupPeersHandlingMessage <MessageProcessingFailed>(_peerUp);

                _bus.Start();

                var command = new FakeCommand(123);

                _messageSerializer.AddSerializationExceptionFor(command.TypeId(), "Serialization error");

                using (SystemDateTime.PauseTime())
                    using (MessageId.PauseIdGeneration())
                    {
                        var transportMessage = command.ToTransportMessage();

                        var messageProcessingFailedBytes = new MessageProcessingFailed(null, null, null, DateTime.UtcNow, null).ToTransportMessage().Content;
                        _messageSerializer.AddSerializationFuncFor <MessageProcessingFailed>(x =>
                        {
                            x.FailingMessage.ShouldEqual(transportMessage);
                            x.ExceptionUtcTime.ShouldEqual(SystemDateTime.UtcNow);
                            x.ExceptionMessage.ShouldContain("Unable to deserialize message");
                            return(messageProcessingFailedBytes);
                        });

                        _transport.RaiseMessageReceived(transportMessage);

                        var processingFailedTransportMessage = new TransportMessage(MessageUtil.TypeId <MessageProcessingFailed>(), messageProcessingFailedBytes, _self);
                        _transport.ExpectExactly(new TransportMessageSent(processingFailedTransportMessage, _peerUp));
                    }
            }
            public void should_ack_transport_when_handling_undeserializable_message()
            {
                var command = new FakeCommand(123);

                _messageSerializer.AddSerializationExceptionFor(command.TypeId());

                var transportMessage = command.ToTransportMessage();

                _transport.RaiseMessageReceived(transportMessage);

                _transport.AckedMessages.ShouldContain(transportMessage);
            }
            public void should_dump_incoming_message_if_unable_to_deserialize_it()
            {
                var command = new FakeCommand(123);

                _messageSerializer.AddSerializationExceptionFor(command.TypeId());

                var transportMessage = command.ToTransportMessage();

                _transport.RaiseMessageReceived(transportMessage);

                var dumpFileName = System.IO.Directory.GetFiles(_bus.DeserializationFailureDumpDirectoryPath).ExpectedSingle();

                dumpFileName.ShouldContain("Abc.Zebus.Tests.Messages.FakeCommand");
                File.ReadAllBytes(dumpFileName).Length.ShouldEqual(2);
            }
Exemplo n.º 4
0
            public void should_send_a_CustomProcessingFailed_on_error_with_local_processing_and_unserializable_message()
            {
                SetupPeersHandlingMessage <CustomProcessingFailed>(_peerUp);

                _bus.Start();

                using (SystemDateTime.PauseTime())
                    using (MessageId.PauseIdGeneration())
                    {
                        SetupPeersHandlingMessage <FakeCommand>(_self);

                        var command = new FakeCommand(123);
                        SetupDispatch(command, error: new Exception("Dispatch exception"));

                        _messageSerializer.AddSerializationExceptionFor(command.TypeId(), exceptionMessage: "Serialization exception");

                        _bus.Send(command);

                        var error = _transport.MessagesSent.OfType <CustomProcessingFailed>().ExpectedSingle();
                        error.ExceptionMessage.ShouldContain("Dispatch exception");
                        error.ExceptionMessage.ShouldContain("Serialization exception");
                        error.ExceptionMessage.ShouldContain(command.GetType().FullName);
                    }
            }