Turn on the trace-level logging for ActiveMQ in your client application to see more details about sent messages. The messages can and will contain lots of "metadata" the brokers and clients use, for example sending a simple test-message within our own server software shows the following:
[scheduler-1] TRACE org.apache.activemq.ActiveMQSession -
ID:esaj-HP-59250-1410162276798-1:1:36 sending message:
ActiveMQTextMessage {commandId = 0, responseRequired = false,
messageId = ID:esaj-HP-59250-1410162276798-1:1:36:1:2,
originalDestination = null, originalTransactionId = null, producerId =
ID:esaj-HP-59250-1410162276798-1:1:36:1, destination =
topic://server.diagnostics, transactionId = null, expiration =
1410162336586, timestamp = 1410162324586, arrival = 0, brokerInTime =
0, brokerOutTime = 0, correlationId = null, replyTo = null, persistent
= false, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content =
null, marshalledProperties = null, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {** OMITTED, OUR CUSTOM PROPS **
}, readOnlyProperties = true, readOnlyBody = true, droppable
= false, jmsXGroupFirstForConsumer = false, text = { ** THE ACTUAL DATA **
}}
This was with ActiveMQ 5.9, but as you can see, there's lots of header data that ActiveMQ produces on its own. As for how to actually get rid of it, I'm not sure, I'm not really an ActiveMQ-specialist, but I'd say a kilobyte of header data seems just "normal" for ActiveMQ.
Edit: I took a look into our message brokers, and all queues and topics show average message sizes above 1024 bytes, which lead me to delve a bit into the ActiveMQ (5.9) source. I found this in org.apache.activemq.command.Message:
/**
* The default minimum amount of memory a message is assumed to use
*/
public static final int DEFAULT_MINIMUM_MESSAGE_SIZE = 1024;
//Omitted other stuff...
@Override
public int getSize() {
int minimumMessageSize = getMinimumMessageSize();
if (size < minimumMessageSize || size == 0) {
size = minimumMessageSize;
if (marshalledProperties != null) {
size += marshalledProperties.getLength();
}
if (content != null) {
size += content.getLength();
}
}
return size;
}
protected int getMinimumMessageSize() {
int result = DEFAULT_MINIMUM_MESSAGE_SIZE;
//let destination override
MessageDestination dest = regionDestination;
if (dest != null) {
result=dest.getMinimumMessageSize();
}
return result;
}
And getSize() is used in many places, like MessageQueue, ActiveMQSession etc. I didn't delve much deeper, but it looks like at least 1024 bytes (1 kilobyte) is either reserved or at least assumed in statistics for each message. The statistics seem to be gathered in Queue- and Topic-classes, and uses the value returned by getSize()
, here's for example the beginning of Queue.messageSent:
final void messageSent(final ConnectionContext context, final Message msg) throws Exception {
destinationStatistics.getEnqueues().increment();
destinationStatistics.getMessages().increment();
destinationStatistics.getMessageSize().addSize(msg.getSize());
I don't know whether 1024 bytes is actually transmitted over the wire when sending an empty message, but at least the statistics seem to assume so.