8.3. ブリッジの設定
以下のコードは、すべての属性を示すメッセージブリッジの設定例です。一度にすべての属性を指定すべきではないため、この設定では一部コメントアウトしている属性があります。
例8.1 メッセージブリッジの設定
<mbean code="org.jboss.jms.server.bridge.BridgeService"
name="jboss.messaging:service=Bridge,name=TestBridge"
xmbean-dd="xmdesc/Bridge-xmbean.xml">
<!-- The JMS provider loader that is used to lookup the source
destination
-->
<depends optional-attribute-name="SourceProviderLoader">
jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>
<!-- The JMS provider loader that is used to lookup the target
destination
-->
<depends optional-attribute-name="TargetProviderLoader">
jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>
<!-- The JNDI lookup for the source destination -->
<attribute name="SourceDestinationLookup">/queue/A</attribute>
<!-- The JNDI lookup for the target destination -->
<attribute name="TargetDestinationLookup">/queue/B</attribute>
<!-- The username to use for the source connection
<attribute name="SourceUsername">bob</attribute>
-->
<!-- The password to use for the source connection
<attribute name="SourcePassword">BobSecur3</attribute>
-->
<!-- The username to use for the target connection
<attribute name="TargetUsername">mary</attribute>
-->
<!-- The password to use for the target connection
<attribute name="TargetPassword">MaryS3cur3</attribute>
-->
<!-- Optional: The Quality Of Service mode to use, one of:
QOS_AT_MOST_ONCE = 0;
QOS_DUPLICATES_OK = 1;
QOS_ONCE_AND_ONLY_ONCE = 2;
-->
<attribute name="QualityOfServiceMode">0</attribute>
<!-- JMS selector to use for consuming messages from the source
<attribute name="Selector">specify jms selector here</attribute>
-->
<!-- The maximum number of messages to consume from the source
before sending to the target
-->
<attribute name="MaxBatchSize">5</attribute>
<!-- The maximum time to wait (in ms) before sending a batch to the
target even if MaxBatchSize is not exceeded. -1 means wait forever
-->
<attribute name="MaxBatchTime">-1</attribute>
<!-- If consuming from a durable subscription this is the subscription
name
<attribute name="SubName">mysub</attribute>
-->
<!-- If consuming from a durable subscription this is the client ID to
use
<attribute name="ClientID">myClientID</attribute>
-->
<!-- The number of ms to wait between connection retrues in the event
connections to source or target fail
-->
<attribute name="FailureRetryInterval">5000</attribute>
<!-- The maximum number of connection retries to make in case of failure,
before giving up -1 means try forever
-->
<attribute name="MaxRetries">-1</attribute>
<!-- If true then the message ID of the message before bridging will be
added as a header to the message so it is available to the
receiver. Can then be sent as correlation ID to correlate in a
distributed request-response
-->
<attribute name="AddMessageIDInHeader">false</attribute>
</mbean>
メッセージブリッジ設定の属性
- SourceProviderLoader, TargetProvider Loader
JMSProviderLoader管理 Bean は、ブリッジによってソースの接続ファクトリとソースのデスティネーションの検索に使用されます。デフォルトでは、JBoss Enterprise Application Platform にはJMSProviderLoaderが 1 つ同梱され、$JBOSS_HOME/server/$PROFILE/deploy/messaging/jms-ds.xmlファイルでデプロイされ、デフォルトのローカルJMSProviderLoaderとして動作します。クラスター化した設定では、hajndi-jms-ds.xmlが同じ役割を果たします。ソースまたは目的のデスティネーションが異なるサーバーにある場合、または JBoss JMS Provider 以外に対応する場合、リモート JMS Provider のデスティネーションとコンタクトするためにブリッジが使用できる別のJMSProviderLoader管理 Bean インスタンスをデプロイすることができます。JBoss Messaging 以外のリモートのソースまたは目的のデスティネーションでQOS_ONCE_AND_ONLY_ONCEの配信を使用するためには、リモート JMS Provider は、サーバーからリモートで動作する完全機能の JMS XA リソース実装を提供する必要があります。- SourceDestinationLookup
/queue/mySourceQueueなどSourceProviderLoaderによるソースのデスティネーションの完全な JNDI 検索です。- TargetDestinationLookup
/topic/myTargetTopicなどTargetProviderLocatorによる目的のデスティネーションの完全な JNDI 検索です。- SourceUsername
- ソース接続の作成時に使用するユーザー名を指定するオプションの属性です。
- SourcePassword
- ソース接続の作成時に使用するパスワードを指定するオプションの属性です。
- TargetUsername
- 目的の接続の作成時に使用するユーザー名を指定するオプションの属性です。
- TargetPassword
- 目的の接続の作成時に使用するパスワードを指定するオプションの属性です。
- QualityOfServiceMode
- 目的の サービスの質 のモードを表す整数です。可能性のある値は次のとおりです。
0はQOS_AT_MOST_ONCEを表します。1はQOS_DUPLICATES_OKを表します。2はQOS_ONCE_AND_ONLY_ONCEを表します。
これらモードの詳細な説明については 「メッセージブリッジの概要」 を参照してください。 - Selector
- ソースのデスティネーションからメッセージをコンシュームする時に、JMS セレクター式を与えることができるオプションの属性です。セレクター式に一致するメッセージだけがソースから目的のデスティネーションまでブリッジされます。セレクター式は、http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html で指定されている JMS セレクターの構文に従う必要があります。最適なパフォーマンスを得るには、ソーストピックサブスクリプションのセレクターをソースキューのコンシューマーに適用します。
- MaxBatchSize
- 目的のデスティネーションにメッセージのバッチを送信するまでにソースのデスティネーションからコンシュームする最大メッセージ数を指定します。値は
1かそれ以上である必要があります。 - MaxBatchTime
MaxBatchSizeに到達していなくても、メッセージのバッチを目的に送信するまでに待機する最長時間(ミリ秒単位)を指定します。値は-1(永久に待機)、または時間を指定する1かそれ以上である必要があります。- SubName
- ソースのデスティネーショントピックからコンシュームする持続性のあるサブスクリプションの名前を表します。
- ClientID
- ソースのデスティネーショントピックからコンシュームする持続性のあるサブスクリプションの作成または検索時に使用する JMS クライアント ID を表します。
- FailureRetryInterval
- 障害が検出されてからソースまたは目的のサーバーに接続の再作成を試行する間の待機時間(ミリ秒単位)です。
- MaxRetries
- 障害が検出されてからソースまたは目的のサーバーに接続の再作成を試行する回数です。この後、ブリッジは接続の再作成の試行を停止します。
-1の値は、ブリッジが再接続の試行を永久に続けるという意味です。 - AddMessageIDInHeader
trueに設定すると、オリジナルのメッセージ ID はデスティネーションに送信されたメッセージのJBossMessage.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LISTヘッダに追加されます。メッセージが複数回ブリッジされると、それぞれのメッセージ ID はヘッダに追加されます。これにより、分散型要求応答パターンが使用できるようになります。