Should the producing client store data in a message's header or its body?

Jerry Smith

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.

If messages potentially transport a large amount of data, and consuming clients are interested in only certain data-laden messages, it makes sense to put the data in the message and a coordinating, or identifying, property name and value in the header, in order to maximize the message selection/filtering capabilities that are available with JMS.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact