Should the producing client store data in a message's header or its body?
Decisions regarding where to store data should be based on the following guidelines:
- The primary purpose of the header is to identify and route messages.
- JMS does not provide a consuming client with access to the message body until the message is consumed. (QueueBrowser does not provide static snapshots.)
- It's more likely that "large quantities of data" will be handled more efficiently in message bodies than in the message header as property values.
If consuming clients will be using the data to filter the messages they receive from the JMS server, this data should be small and stored as a message property. In this case, any inefficiencies related to "top-heavy" headers, data conversions to and from strings, and so on will more than likely be offset by the savings in not having to delivery a significant percentage of the messages to a consuming client(s), depending on the message selecting criteria.