public void Execute(OnDeserializeTransportMessage pipelineEvent) { var state = pipelineEvent.Pipeline.State; var receivedMessage = state.GetReceivedMessage(); var workQueue = state.GetWorkQueue(); var errorQueue = state.GetErrorQueue(); Guard.AgainstNull(receivedMessage, nameof(receivedMessage)); Guard.AgainstNull(workQueue, nameof(workQueue)); Guard.AgainstNull(errorQueue, nameof(errorQueue)); TransportMessage transportMessage; try { using (var stream = receivedMessage.Stream.Copy()) { transportMessage = (TransportMessage)_serializer.Deserialize(typeof(TransportMessage), stream); } } catch (Exception ex) { _log.Error(ex.ToString()); _log.Error(string.Format(Resources.TransportMessageDeserializationException, workQueue.Uri.Secured(), ex)); if (_configuration.RemoveCorruptMessages) { state.GetWorkQueue().Acknowledge(state.GetReceivedMessage().AcknowledgementToken); } else { if (!_environmentService.UserInteractive) { _processService.GetCurrentProcess().Kill(); } return; } _events.OnTransportMessageDeserializationException(this, new DeserializationExceptionEventArgs( pipelineEvent, workQueue, errorQueue, ex)); pipelineEvent.Pipeline.Abort(); return; } state.SetTransportMessage(transportMessage); state.SetMessageBytes(transportMessage.Message); transportMessage.AcceptInvariants(); }
public void Execute(OnDeserializeTransportMessage pipelineEvent) { var state = pipelineEvent.Pipeline.State; var receivedMessage = state.GetReceivedMessage(); var workQueue = state.GetWorkQueue(); var errorQueue = state.GetErrorQueue(); Guard.AgainstNull(receivedMessage, nameof(receivedMessage)); Guard.AgainstNull(workQueue, nameof(workQueue)); Guard.AgainstNull(errorQueue, nameof(errorQueue)); TransportMessage transportMessage; try { using (var stream = receivedMessage.Stream.Copy()) { transportMessage = (TransportMessage)_serializer.Deserialize(typeof(TransportMessage), stream); } } catch (Exception ex) { _log.Error(ex.ToString()); _log.Error(string.Format(EsbResources.TransportMessageDeserializationException, workQueue.Uri.Secured(), ex)); state.GetWorkQueue().Acknowledge(state.GetReceivedMessage().AcknowledgementToken); _events.OnTransportMessageDeserializationException(this, new DeserializationExceptionEventArgs( pipelineEvent, workQueue, errorQueue, ex)); pipelineEvent.Pipeline.Abort(); return; } state.SetTransportMessage(transportMessage); state.SetMessageBytes(transportMessage.Message); transportMessage.AcceptInvariants(); }