-
1. Re: Read serialized bytes of Object Message as it arrives
timfox Oct 6, 2009 5:40 AM (in response to rnicholson10)If you're using the JMS API, just use a BytesMessage and do the serialization yourself.
-
2. Re: Read serialized bytes of Object Message as it arrives
rnicholson10 Oct 6, 2009 5:46 AM (in response to rnicholson10)I would certainly do that if it was possible. Unfortunately I don't have access to the code that creates the object message in the first place.
Is it possible to do this at all? Otherwise I can put through a dev request to get this change made and just re-serialize the object myself for the moment.
Thanks for your help,
Ross -
3. Re: Read serialized bytes of Object Message as it arrives
timfox Oct 6, 2009 5:53 AM (in response to rnicholson10)You could cast the message to a HornetQObjectMessage then call getCoreMessage() to get the underlying core ClientMessage.
Once you've got that you can manipulate the body directly. -
4. Re: Read serialized bytes of Object Message as it arrives
rnicholson10 Oct 6, 2009 7:37 AM (in response to rnicholson10)Ok,
So once I have the ClientMessage how do I then get the bytes representing the object?
Currently I've tried:byte[] bytes = hqMessage.getCoreMessage().getBody().array();
But this does not seem to be the bytes representing the object but the entire body. What's the process for getting only the object bytes from this point.
R. -
5. Re: Read serialized bytes of Object Message as it arrives
timfox Oct 6, 2009 7:43 AM (in response to rnicholson10)The entire body is the object.
Take a look at the source of HornetQObjectMessage to see exactly what is stored. -
6. Re: Read serialized bytes of Object Message as it arrives
timfox Oct 6, 2009 7:46 AM (in response to rnicholson10)I guess it goes without saying, but doing this will make your code very brittle, but I'm just demonstrating it is possible.
-
7. Re: Read serialized bytes of Object Message as it arrives
rnicholson10 Oct 6, 2009 8:03 AM (in response to rnicholson10)Yes, I understand this.
I really want this to check what the overhead would be with
"unserialise and serialise again" vs "the single unserailise" (the hack).
If I can prove the overhead it costs I can probably request the code change so they send byte messages instead of object messages.
Brittle yes, but only for a short time... I hope!
Thanks for your help. -
8. Re: Read serialized bytes of Object Message as it arrives
clebert.suconic Oct 7, 2009 12:38 AM (in response to rnicholson10)"If I can prove the overhead it costs I can probably request the code change so they send byte messages instead of object messages. "
Take the advice of someone who wrote a whole serialization library. Serialization is really costly. Lots of metadata... It's like running your marshalling at full interpreted mode.
If you use serialization. At least provide full Externalization, and don't trust the Serializaton code to create new objects for you (minimize internal writeObject calls), so you only have one metadata being used. But on that case at the end is just easy to not use serialization at all ;-)