4 Replies Latest reply on Mar 31, 2004 6:49 AM by thoennes

    JMS Object Serialization

    chris_white

      Is it possible, and if so could anyone point me in the right direction, to provide custom serialization streams so i can compress my JMS payload objects and decompress at the recipient ??.

      You can use GZIPOutputStream to compress data to an output stream, but how do i declare that all JMS serialization uses this as its default output stream/input stream ??

      Thanks

      Chris

        • 1. Re: JMS Object Serialization
          chris_white

          Sorry for the x3 topic creation, but the forum encountered errors when i went to submit and apparently the topic 'did not exists'.

          • 2. Re: JMS Object Serialization
            genman

            There is no facility for compressing all data stored. However, you can create a wrapper for your compressible Objects:

            import java.io.*;
            import java.util.zip.GZIPOutputStream;
            
            public class CompressedSerializable
             implements Serializable
            {
            
             private Serializable o; // uncompressed object
            
             public CompressedSerializable(Serializable o) {
             this.o = o;
             }
            
             private void writeObject(java.io.ObjectOutputStream out)
             throws IOException
             {
             ObjectOutputStream oos =
             new ObjectOutputStream(new GZIPOutputStream(out));
             oos.write(o);
             oos.flush();
             }
            
             private void readObject(java.io.ObjectInputStream in)
             throws IOException, ClassNotFoundException;
            }


            You could, of course, modify UIL2 yourself and post a patch. It probably would be easy to find the code that sends the payload and GZIP it if a flag is set.


            • 3. Re: JMS Object Serialization

              All the tcp/ip connection factories take customizable socket factories.
              See docs/examples/jms/https-service.xml where ssl sockets are configured.

              The JBoss testsuite contains implementations of GZIP socket factories.
              http://cvs.sourceforge.net/viewcvs.py/jboss/jbosstest/src/main/org/jboss/test/invokers/ejb/

              Regards,
              Adrian

              • 4. Re: JMS Object Serialization
                thoennes

                Please also note, that using the standard Java GZipOutputStream has some severe
                limitations: If you do a flush which is necessary after each serialized object written to
                the stream, you basically loose your complete compression dictionary. The behaviour is
                then as if you compress every object alone. In this case, there is no advantage of the
                GZipSocket over the compressed payload object.

                See the related bug in the bug parade:

                http://developer.java.sun.com/developer/bugParade/bugs/4813885.html

                Cheers, Joerg