Thanks for the fast responses! I'm using XML serialization.
Using the Message URN directly allows me to show the message type. I just strip out the "urn:message:" part.
But I'd still like to deserialize and call ToString on the deserialized object to get a summary of the message. This works, however, it requires that I know the type at compile time (and it may not be the simplest way to do this).
BasicGetResult getResult = //get from RabbitMQ
MemoryStream bodyStream = new MemoryStream(getResult.Body);
ReceiveContext receive = ReceiveContext.FromBodyStream(bodyStream);
XmlMessageSerializer serializer = new XmlMessageSerializer();
serializer.Deserialize(receive);
IConsumeContext<MyMessageClass> consume;
receive.TryGetContext(out consume);
MyMessageClass message = consume.Message;
I saw some information about using Magnum's FastInvoke to invoke a generic method with a type determined at run-time. However, I'm not able to get the type at run-time as the message urn doesn't contain the assembly name, only the namespace.
I can have an assembly per namespace, which should allow MessageUrn.GetType() to work. Or, I can use reflection to scan all the loaded types to look for the match. Is there another way?
Thanks.
Clay