public SerializableMessage(Message fromMessage) { DeliveryTag = fromMessage.DeliveryTag; Redelivered = fromMessage.Redelivered; Exchange = fromMessage.Exchange; RoutingKey = fromMessage.RoutingKey; Queue = fromMessage.Queue; Properties = new SerializableMessageProperties(fromMessage.Properties); // If this is detected as a JSON message, include the object directly in the JSON line so that it is easier // to read and process in the output file. Otherwise simply include the raw data and let Newtonsoft encode it. // This does mean the message will be rewritten. If this is an issue, feel free to add a "raw" option to this tool // that forces the RawBody to be used. It is open-source after all :-). if (Properties.ContentType == "application/json") { try { Body = JObject.Parse(Encoding.UTF8.GetString(fromMessage.Body)); RawBody = null; } catch { // Fall back to using the raw body Body = null; RawBody = fromMessage.Body; } } else { Body = null; RawBody = fromMessage.Body; } }
// ReSharper disable once UnusedMember.Global - used by JSON deserialization // ReSharper disable once UnusedMember.Local public SerializableMessage() { Properties = new SerializableMessageProperties(); }