2 Replies Latest reply on May 15, 2010 3:02 AM by timfox

    Attaching Transient properties to delivered messages

    bill.burke

      Consider this scenario:

       

      There are multiple consumers of a Topic.  These consumers consume Java objects but transform these Java objects into JSON before sending them off to some HTTP client.  Is it possible to cache this transformation within the Message?  I know HornetQ does message referencing, but when are copies made and can transient properties be attached post-delivery?

       

      Thanks

        • 1. Re: Attaching Transient properties to delivered messages
          clebert.suconic

          If you are using core-api, you could just use regular properties.

           

           

          Each message on the consumer will be a copy (on the consumer). It's just a reference on the server, but after received the messages are copies.

           

           

          If you're using JMS.. I'm not sure how you would do it.. since message are read-only after received, as required per spec.

           

           

          I'm attaching two tests you could verify this yourself.

          • 2. Re: Attaching Transient properties to delivered messages
            timfox

            Clebert Suconic wrote:

             

            If you are using core-api, you could just use regular properties.

             

             

            Each message on the consumer will be a copy (on the consumer). It's just a reference on the server, but after received the messages are copies.

             

             

            If you're using JMS.. I'm not sure how you would do it.. since message are read-only after received, as required per spec.

             

             

            I'm attaching two tests you could verify this yourself.

            Assuming Bill is plugging in at the server side, that won't work. The message in the ServerConsumerImpl is not a copy - there is only one per topic.

             

            Bill will have to create his own holder class which keeps a reference to the Message and his information that he wants to cache.

             

            Alternatively could just call copy() on the Message instance and cache that.