7 Replies Latest reply on Dec 1, 2009 5:46 PM by timfox

    Alternatives to ObjectMessage

    rnicholson10

      I am wondering about suitable alternative to ObjectMessages.

      I know ObjectMessages are always serialized. But what about MapMessages?

      If I avoid setting Objects in a MapMessage does this mean this won't be serialized? How should I go about sending null values?

      Or is a better alternative just to send everything as a String and parse it back when received?

        • 1. Re: Alternatives to ObjectMessage
          rnicholson10

          The reason I ask is that we will starting perfomance testing next week. I'd like to be able to try an alternative to ObjectMessage and measure the performance differences.

          • 2. Re: Alternatives to ObjectMessage
            clebert.suconic

            Really the best is you doing your own marshalling and putting everything as Bytes into a BytesMessage. (or depending on the size, on a Largemessage (see the large message chapter)).

            On the server's side, the Objectmessage is just a Message with a ByteArray as a body. But I guess I have seen you mentioning you're using those ObjectMessages on the Server's side (such as JSPs, servlets.. etc).

            • 3. Re: Alternatives to ObjectMessage
              timfox

               

              "clebert.suconic@jboss.com" wrote:
              Really the best is you doing your own marshalling and putting everything as Bytes into a BytesMessage. (or depending on the size, on a Largemessage (see the large message chapter)).


              That's unnecessary.

              All the JMS Object types, MapMessage, StreamMessage, TextMessage, BytesMessage *apart* from ObjectMessage do not use Java serialization, and have a compact and efficient encoding and wireformat size.

              So, the short answer is, if you're using JMS, using any type other than ObjectMessage is good.

              • 4. Re: Alternatives to ObjectMessage
                timfox

                If you use, say, Map message, make sure you only put basic types String, int, long, boolean etc.

                If you put arbitrary java objects, of course that will use Java serialization too!

                • 5. Re: Alternatives to ObjectMessage
                  timfox

                  Ah duh! MapMessage will only let you put the basic types anyway - you can't put arbitrary objects so ignore my last comment.

                  • 6. Re: Alternatives to ObjectMessage
                    jhakim

                    Tim - your last comment is spot on for an enhancement request of mine. We use TIBCO EMS, ActiveMQ, and Messageforge for a very successful bond trading platform. Both EMs and ActiveMQ provide extensions that allow a MapMessage to contain structured data - EMS allows nested MapMessage and ActiveMQ allows nested Map. The power of nested (recursive) structured data is immense.

                    Would HornetQ consider providing such an extension?

                    • 7. Re: Alternatives to ObjectMessage
                      timfox

                      We could do this, but the down side to it, is it encourages lazy practices by developers.

                      As soon as we accept an arbitrary serializable object to be added, then typically developers will throw in the kitchen sink and expect it to be serialized efficiently.

                      If you don't care about performance, then serializing hierarchies of nested objects can be done, but it will be slow.

                      It is usually far more efficient for developers to intelligently martial their data using the other message types and not relying on Object serialization.