tags:

views:

23

answers:

1

Hi all ActiveMQ experts!

I had a look via WireShark what's happening under the hood when ActiveMQ "/examples" producer sends messages and it revealed that every TextMessage shorter than 1000 bytes is padded with spaces (' ' or HEX 20) until it fills exactly 1000 bytes. (using the ActiveMQ's "native" transport - TCP "OpenWire")

Wonder what is doing that? (I presume the ActivemQ JMS Client implementation) but WHY??

And most importantly, is there a way to optimize it so that sending short messages does not incur almost 1K overhead of unnecessary spaces?

Thank you!

cheers, O.K.

+1  A: 

Your are correct that the client implementation is adding the spaces to the messages (see the createMessageText method). This is simply so that the messages are an even size. You can either change the size when running the example (use the arg: -DmessageSize=<size>) or you can change the ProducerTool so that it does not pad each message by simply editing the code and running it again (Ant will compile it before running it). I've done this many times to remove the spaces altogether, to add extra text to the message, to add message headers, to format the message body using XML, etc.

Bruce

bsnyder
Thanks a lot, Bruce!I am actually embarrassed now for not figuring it out myself (not looking in producer code).Also, can you recommend a resource describing the low-level communications happening under OpenWire protocol?There is this page: http://activemq.apache.org/openwire-version-2-specification.htmlbut it mostly describes formats and encodings, when I am more after the conversation sequences happening between client and server during connection establishing, sending, ACKing, "keep alives" etcThank you!cheers,O.K.PS: Enjoying your eBook draft - when's final coming?
Oleg Kiorsak
No problem, Oleg. The only other place to find more detail about OpenWire is in the ActiveMQ source code. According to Manning, the book should be out in Sept/Oct perhaps. We will see.
bsnyder