开发者

Why is ActiveMQ TextMessage padded with spaces to fill in 1000 bytes?? How to optimize it?

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?开发者_C百科 (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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜