public QueueMessageVisualization get_message_Port_QueueName_SourceInstanceId_MessageId(MessageInputModel input)
        {
            var messageId = MessageId.Parse($"{input.SourceInstanceId}/{input.MessageId}");

            var message = retrieveMessage(messageId, input.Port, input.QueueName);

            if (message == null)
            {
                return new QueueMessageVisualization {NotFound = true};
            }

            var model = new QueueMessageVisualization
            {
                MessageId = messageId,
                QueueName = message.Queue,
                SentAt = message.SentAt,
                Headers = message.Headers,
                Port = input.Port
            };
            try
            {
                object payload;
                var envelope = message.ToEnvelope();
                envelope.UseSerializer(_serializer);
                if (input.QueueName == "errors")
                {
                    var errorReport = ErrorReport.Deserialize(message.Data);
                    message = new Message
                    {
                        Data = errorReport.RawData,
                        Headers = errorReport.Headers,
                        Id = messageId,
                        Queue = input.QueueName,
                    };
                    envelope = message.ToEnvelope();
                    var originalMessage = _serializer.Deserialize(envelope);
                    var errorSummary = new ErrorSummary
                    {
                        exceptiontype = errorReport.ExceptionType,
                        exceptionmessage = errorReport.ExceptionMessage,
                        exceptiontext = errorReport.ExceptionText,
                        originalmessage = originalMessage
                    };
                    payload = errorSummary;
                }
                else
                {
                    payload = envelope.Message;
                }


                model.Payload = JsonSerialization.ToJson(payload, true);
            }
            catch (Exception)
            {
                model.Payload = "Could not render as JSON";
            }

            return model;
        }
        public QueueMessageVisualization get_message_Port_QueueName_SourceInstanceId_MessageId(
            MessageInputModel input)
        {
            var messageId = new MessageId
            {
                MessageIdentifier = input.MessageId,
                SourceInstanceId  = input.SourceInstanceId
            };

            var message = retrieveMessage(messageId, input.Port, input.QueueName);

            if (message == null)
            {
                return(new QueueMessageVisualization {
                    NotFound = true
                });
            }

            var envelope = message.ToEnvelope();

            envelope.UseSerializer(_serializer);

            // TODO -- show errors if in error queue

            var model = new QueueMessageVisualization
            {
                MessageId    = messageId,
                QueueName    = message.Queue,
                SubQueueName = message.SubQueue,
                Status       = message.Status,
                SentAt       = message.SentAt,
                Headers      = message.Headers.ToDictionary(),
                Port         = input.Port
            };

            try
            {
                // TODO -- gotta watch how big this monster would be
                model.Payload = JsonSerialization.ToJson(envelope.Message, true);
            }
            catch (Exception)
            {
                model.Payload = "Could not render as JSON";
            }

            return(model);
        }
        public QueueMessageVisualization get_message_Port_QueueName_SourceInstanceId_MessageId(
            MessageInputModel input)
        {
            var messageId = new MessageId
            {
                MessageIdentifier = input.MessageId,
                SourceInstanceId = input.SourceInstanceId
            };

            var message = retrieveMessage(messageId, input.Port, input.QueueName);

            if (message == null)
            {
                return new QueueMessageVisualization {NotFound = true};
            }

            var envelope = message.ToEnvelope();
            envelope.UseSerializer(_serializer);

            // TODO -- show errors if in error queue

            var model = new QueueMessageVisualization
            {
                MessageId = messageId,
                QueueName = message.Queue,
                SubQueueName = message.SubQueue,
                Status = message.Status,
                SentAt = message.SentAt,
                Headers = message.Headers.ToDictionary(),
                Port = input.Port

            };

            try
            {
                // TODO -- gotta watch how big this monster would be
                model.Payload = JsonSerialization.ToJson(envelope.Message, true);
            }
            catch (Exception)
            {
                model.Payload = "Could not render as JSON";
            }

            return model;
        }
示例#4
0
        public QueueMessageVisualization get_message_Port_QueueName_SourceInstanceId_MessageId(MessageInputModel input)
        {
            var messageId = MessageId.Parse($"{input.SourceInstanceId}/{input.MessageId}");

            var message = retrieveMessage(messageId, input.Port, input.QueueName);

            if (message == null)
            {
                return(new QueueMessageVisualization {
                    NotFound = true
                });
            }

            var model = new QueueMessageVisualization
            {
                MessageId = messageId,
                QueueName = message.Queue,
                SentAt    = message.SentAt,
                Headers   = message.Headers,
                Port      = input.Port
            };

            try
            {
                object payload;
                var    envelope = message.ToEnvelope();
                envelope.UseSerializer(_serializer);
                if (input.QueueName == "errors")
                {
                    var errorReport = ErrorReport.Deserialize(message.Data);
                    message = new Message
                    {
                        Data    = errorReport.RawData,
                        Headers = errorReport.Headers,
                        Id      = messageId,
                        Queue   = input.QueueName,
                    };
                    envelope = message.ToEnvelope();
                    var originalMessage = _serializer.Deserialize(envelope);
                    var errorSummary    = new ErrorSummary
                    {
                        exceptiontype    = errorReport.ExceptionType,
                        exceptionmessage = errorReport.ExceptionMessage,
                        exceptiontext    = errorReport.ExceptionText,
                        originalmessage  = originalMessage
                    };
                    payload = errorSummary;
                }
                else
                {
                    payload = envelope.Message;
                }


                model.Payload = JsonSerialization.ToJson(payload, true);
            }
            catch (Exception)
            {
                model.Payload = "Could not render as JSON";
            }

            return(model);
        }