How to get base stream descriptor from ActiveMQ Apache NMS message

Background:
C # WPF Application using JAVA Server running on Linux via ActiveMQ (Apache.NMS) / JSON (Newtonsoft.Json)

Problem :
JSON messages larger than 85000 bytes result in LOH fragmentation

Possible solution:
Instead of reading JSON as Apache.NMS.ITextMessage (which is currently the case) get the handle to the main thread and deserialize with JsonTextReader

Implementation Issues:
It would appear that this is not supported by the Apache.NMS API, although there are ActiveMQStreamMessage / ActiveMQBytesMessage options that really don't fit the bill here.

I would like to know if anyone has any experience above?

+3


source to share


1 answer


Well, if you agree to skip the "pure" NMS api and access the ActiveMQ classes, you can get the handle to the MemoryStream via the public property Content. There might be compression you need to deal with.



                    ITextMessage msg = consumer.Receive () as ITextMessage;
                    ActiveMQTextMessage tmsg = msg as ActiveMQTextMessage;
                    Stream stream = new MemoryStream(tmsg.Content);

                    if(tmsg.Compressed == true)
                    {
                        stream = tmsg.Connection.CompressionPolicy.CreateDecompressionStream(stream);                            
                    }

                    // TODO read MemoryStream to whatever

      

0


source







All Articles