Unable to get map message from jBOSS JMS using nms.stomp in c#

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Unable to get map message from jBOSS JMS using nms.stomp in c#

sumoaps@outlook.com
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello Folks,

I am trying to connect JBOSS Hornet Q using c# with nms.stomp api.I am able to get the text messages but unable to get Map Message and Object message.I looked through the source of apache.nms and found that in StompWireFormat.cs class,ReadMessage(StompFrame frame) is not returning the map message object.When I dig deep into XmlPrimitiveMapMarshaler class,I see that essentialy the byte[] recieved is decoded via UTF8 and then tried to convert in map but in my case this decode is returning empty string.
Please help!
Below is method in XmlPrimitiveMapMarshaler class to unmarshal the byte[] received over wire.

public IPrimitiveMap Unmarshal(byte[] mapContent)
        {
            string xmlString;
           
            xmlString = Encoding.UTF8.GetString(mapContent);

            PrimitiveMap result = new PrimitiveMap();

            if (xmlString == null || xmlString == "")
            {
                return result;
            }

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;
            settings.IgnoreProcessingInstructions = true;

            XmlReader reader = XmlReader.Create(new StringReader(xmlString), settings);

            reader.MoveToContent();
            reader.ReadStartElement("map");

            while(reader.Name == "entry")
            {
                reader.ReadStartElement();
                string key = reader.ReadElementContentAsString("string", "");

                Object value = null;

                switch(reader.Name)
                {
                case "char":
                    value = Convert.ToChar(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "double":
                    value = Convert.ToDouble(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "float":
                    value = Convert.ToSingle(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "long":
                    value = Convert.ToInt64(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "int":
                    value = Convert.ToInt32(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "short":
                    value = Convert.ToInt16(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "byte":
                    value = (byte) Convert.ToInt16(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "boolean":
                    value = Convert.ToBoolean(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                case "byte-array":
                    value = Convert.FromBase64String(reader.ReadElementContentAsString());
                    reader.ReadEndElement();
                    break;
                default:
                    value = reader.ReadElementContentAsString();
                    reader.ReadEndElement();
                    break;
                };

                // Now store the value into our new PrimitiveMap.
                result[key] = value;
            }

            reader.Close();

            return result;
        }