検索

第37章 Avoiding Anti-Patterns

download PDF
  • Reuse connections, sessions, consumers, and producers where possible.

    The most common messaging anti-pattern is the creation of a new connection, session, and producer for every message sent or consumed. These objects take time to create and may involve several network round trips, so it is a poor use of resources. Always reuse them.

    注記

    Some popular libraries such as the Spring JMS Template use these anti-patterns. If you are using the Spring JMS Template, you may see poor performance. The Spring JMS Template can only safely be used in an application server which caches JMS sessions, for example, using JCA, and only then for sending messages. It cannot safely be used for synchronously consuming messages, even in an application server.

  • Avoid fat messages.

    Verbose formats such as XML take up a lot of space on the wire and performance suffers as result. Avoid XML in message bodies if you can.

  • Do not create temporary queues for each request.

    This common anti-pattern involves the temporary queue request-response pattern. With the temporary queue request-response pattern, a message is sent to a target, and a reply-to header is set with the address of a local temporary queue. When the recipient receives the message, they process it, and then send back a response to the address specified in the reply-to header. A common mistake made with this pattern is to create a new temporary queue on each message sent, which drastically reduces performance. Instead, the temporary queue should be reused for many requests.

  • Do not use message driven beans unless it is necessary.

    Using MDBs to consume messages is slower than consuming messages using a simple JMS message consumer.

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.