Search

43.2. Tuning JMS

download PDF
Optimization is possible in the following areas when using the JMS API:
  • Disable message id. Use the setDisableMessageID() method on the MessageProducer class to disable message ids if not needed. This decreases the size of the message and also avoids the overhead of creating a unique ID.
  • Disable message time stamp. Use the setDisableMessageTimeStamp() method on the MessageProducer class to disable message timestamps not required.
  • Avoid ObjectMessage. ObjectMessage is convenient but it comes at a cost. The body of a ObjectMessage uses Java serialization to serialize it to bytes. The Java serialized form of even small objects is verbose, resulting in increased server traffic, also Java serialization is slow in comparison to custom marshaling techniques. Only use ObjectMessage if one of the other message types are unsuitable (for example, if the type of payload is unknown until run-time).
  • Avoid AUTO_ACKNOWLEDGE. AUTO_ACKNOWLEDGE mode requires an acknowledgment to be sent from the server for each message received on the client, this means more traffic on the network. If possible, use DUPS_OK_ACKNOWLEDGE, or use CLIENT_ACKNOWLEDGE or a transacted session and batch up many acknowledgments with one acknowledge/commit.
  • Avoid durable messages. By default JMS messages are durable. If really durable messages are not required, set the messages to be non-durable. Durable messages incur much more overhead in persisting them to storage.
  • Batch many sends or acknowledgments in a single transaction. HornetQ will only require a network round trip on the commit, not on every send or acknowledgment.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.