qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From falconair <shahb...@gmail.com>
Subject Re: c# message retreival without resorting to encodings and bytes readers?
Date Tue, 27 Jan 2009 08:24:44 GMT

Looks like I can use the following:
IMessage m = ...
...
Console.WriteLine("Message Received3: " + m.ApplicationHeaders["symbol"]);
Console.WriteLine("Message Received3: " +
m.ApplicationHeaders["symbol"].GetType());
Console.WriteLine("Message Received3: " + m.ApplicationHeaders["price"]);
Console.WriteLine("Message Received3: " +
m.ApplicationHeaders["price"].GetType());
...

Which prints the following:
Message Received3: USDEUR
Message Received3: System.String
Message Received3: 0.7551
Message Received3: System.Double

Perfect!  I now recall that one of the developers pointed this out in an
earlier message.  Perhaps this could be used in the examples as well?


falconair wrote:
> 
> Every .NET example I have seen uses code similar to the following to
> retrieve messages:
> ...IMessage m...
> BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8);
> byte[] body = new byte[m.Body.Length - m.Body.Position];
> reader.Read(body, 0, body.Length);
> ASCIIEncoding enc = new ASCIIEncoding();
> string message = enc.GetString(body);
> 
> Isn't there a way for me to access fields of a message using a more type
> safe way:
> m.getFloat("nameoffloatfield");
> m.getString("nameofstringfield");
> 
> Instead of pointing out flaws, I am actually trying to write a utility
> class which will let users of .NET qpid access messages through a clean
> event based interface...but in order to get there I need the lower layer
> to be a bit saner :)
> 
> Any quick examples of how I retrieve a couple of attributes of different
> types?
> Thanks
> 

-- 
View this message in context: http://n2.nabble.com/c--message-retreival-without-resorting-to-encodings-and-bytes-readers--tp2222774p2222972.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message