If you're using the JMS API, just use a BytesMessage and do the serialization yourself.
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,
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.
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.
The entire body is the object.
Take a look at the source of HornetQObjectMessage to see exactly what is stored.
I guess it goes without saying, but doing this will make your code very brittle, but I'm just demonstrating it is possible.
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.
"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 ;-)