クラス GenericMessageEndpointManager
- 実装されているすべてのインターフェース:
DisposableBean, InitializingBean, Lifecycle, Phased, SmartLifecycle
- 既知の直属サブクラス
JmsMessageEndpointManager
このクラスは、ResourceAdapter、MessageEndpointFactory、および ActivationSpec で機能するという点で完全に汎用的です。次のように、Spring の XML Bean 定義形式などを使用して、標準の Bean スタイルで構成できます。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="jakarta.jms.Queue"/>
</bean>
</property>
</bean>
この例では、Spring 独自の GenericMessageEndpointFactory を使用して、指定されたターゲット ResourceAdapter でサポートされている標準メッセージリスナーオブジェクトを指します。この場合は、ActiveMQ メッセージブローカーでサポートされている JMS MessageListener オブジェクトで、Spring Bean として定義されています。
<bean id="messageListener" class="com.myorg.messaging.myMessageListener"> <!-- ... --> </bean>
ターゲット ResourceAdapter は、ローカル Spring Bean としても構成できます (一般的なケース)。または、JNDI から取得することもできます。上記の例では、ローカル ResourceAdapter Bean は次のように定義できます (上記の "resourceAdapter" Bean 参照に一致)。
<bean id="resourceAdapter" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter">
<bean class="org.apache.activemq.ra.ActiveMQResourceAdapter">
<property name="serverUrl" value="tcp://localhost:61616"/>
</bean>
</property>
<property name="workManager">
<bean class="..."/>
</property>
</bean>
異なるターゲットリソースの場合、構成は単に異なる ResourceAdapter および異なる ActivationSpec オブジェクト (どちらもリソースプロバイダーに固有) を指し、場合によっては異なるメッセージリスナー (たとえば、JCA 共通クライアントインターフェースに基づくリソースアダプターの CCI MessageListener ) を指すことになります。
非同期実行戦略は、上に示すように、ResourceAdapterFactoryBean の "workManager" プロパティを通じてカスタマイズできます。ここで、<bean class="..."/> は、任意の JCA 準拠の WorkManager の構成に置き換える必要があります。
トランザクションの実行は、指定された MessageEndpointFactory によって構築された具体的なメッセージエンドポイントの責任です。GenericMessageEndpointFactory は、通常、Spring JtaTransactionManager またはプレーンな TransactionManager 実装が指定されている "transactionManager" プロパティを通じて XA トランザクションへの参加をサポートします。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
<property name="transactionManager" ref="transactionManager"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="jakarta.jms.Queue"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
または、リソースプロバイダーの ActivationSpec オブジェクトを確認します。このオブジェクトは、プロバイダー固有の構成フラグ (ActiveMQActivationSpec の "useRAManagedTransaction" Bean プロパティなど) を通じてローカルトランザクションをサポートしているはずです。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="jakarta.jms.Queue"/>
<property name="useRAManagedTransaction" value="true"/>
</bean>
</property>
</bean>
- 導入:
- 2.5
- 作成者:
- Juergen Hoeller
- 関連事項:
フィールドのサマリー
インターフェース SmartLifecycle から継承されたフィールド
DEFAULT_PHASEコンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明voidメッセージエンドポイントを準備し、"autoStartup" フラグが "true" に設定されている場合は自動的にアクティブ化します。voiddestroy()メッセージエンドポイントを非アクティブ化し、シャットダウンの準備をします。@Nullable jakarta.resource.spi.ActivationSpecエンドポイントのアクティブ化に使用する JCA ActivationSpec を返します。@Nullable jakarta.resource.spi.endpoint.MessageEndpointFactoryJCA MessageEndpointFactory を返却してアクティブにします。intgetPhase()このエンドポイントマネージャーが開始および停止されるフェーズを返します。@Nullable jakarta.resource.spi.ResourceAdapterエンドポイントを管理する JCA ResourceAdapter を返します。boolean'autoStartup' プロパティの値を返します。boolean設定されたメッセージエンドポイントが現在アクティブかどうかを返します。voidsetActivationSpec(@Nullable jakarta.resource.spi.ActivationSpec activationSpec) エンドポイントのアクティブ化に使用する JCA ActivationSpec を設定します。voidsetAutoStartup(boolean autoStartup) このエンドポイントマネージャーが初期化され、コンテキストがリフレッシュされた後に、エンドポイントのアクティブ化を自動で開始するかどうかを設定します。voidsetMessageEndpointFactory(@Nullable jakarta.resource.spi.endpoint.MessageEndpointFactory messageEndpointFactory) エンドポイントが委譲する MessageListener オブジェクトを指すように、JCA MessageEndpointFactory をアクティブに設定します。voidsetPhase(int phase) この Endpoint Manager を開始および停止するフェーズを指定します。voidsetResourceAdapter(@Nullable jakarta.resource.spi.ResourceAdapter resourceAdapter) エンドポイントを管理する JCA ResourceAdapter を設定します。voidstart()設定されたメッセージエンドポイントをアクティブ化します。voidstop()設定されたメッセージエンドポイントを非アクティブ化します。voidstop(RunnableSE callback) Lifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。クラス ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース SmartLifecycle から継承されたメソッド
isPauseable
コンストラクターの詳細
GenericMessageEndpointManager
public GenericMessageEndpointManager()
メソッドの詳細
setResourceAdapter
エンドポイントを管理する JCA ResourceAdapter を設定します。getResourceAdapter
エンドポイントを管理する JCA ResourceAdapter を返します。setMessageEndpointFactory
public void setMessageEndpointFactory(@Nullable jakarta.resource.spi.endpoint.MessageEndpointFactory messageEndpointFactory) エンドポイントが委譲する MessageListener オブジェクトを指すように、JCA MessageEndpointFactory をアクティブに設定します。MessageEndpointFactory インスタンスは、異なる
ActivationSpecオブジェクトを適用して、複数のエンドポイント(つまり、複数の GenericMessageEndpointManager インスタンス)で共有できます。- 関連事項:
getMessageEndpointFactory
JCA MessageEndpointFactory を返却してアクティブにします。setActivationSpec
エンドポイントのアクティブ化に使用する JCA ActivationSpec を設定します。この ActivationSpec インスタンスを複数の ResourceAdapter インスタンス間で共有しないでください。
getActivationSpec
エンドポイントのアクティブ化に使用する JCA ActivationSpec を返します。setAutoStartup
public void setAutoStartup(boolean autoStartup) このエンドポイントマネージャーが初期化され、コンテキストがリフレッシュされた後に、エンドポイントのアクティブ化を自動で開始するかどうかを設定します。デフォルトは "true" です。このフラグをオフにして、明示的な
start()呼び出しまでエンドポイントのアクティブ化を延期します。isAutoStartup
public boolean isAutoStartup()'autoStartup' プロパティの値を返します。"true" の場合、このエンドポイントマネージャーは ContextRefreshedEvent で起動します。- 次で指定:
- インターフェース
SmartLifecycleのisAutoStartup - 関連事項:
setPhase
public void setPhase(int phase) このエンドポイントマネージャーを開始および停止するフェーズを指定します。起動順序は最低から最高に進み、シャットダウン順序はその逆です。既定では、この値はInteger.MAX_VALUEです。これは、このエンドポイントマネージャーができるだけ遅く開始し、できるだけ早く停止することを意味します。getPhase
public int getPhase()このエンドポイントマネージャーが開始および停止されるフェーズを返します。- 次で指定:
- インターフェース
PhasedのgetPhase - 次で指定:
- インターフェース
SmartLifecycleのgetPhase - 関連事項:
afterPropertiesSet
public void afterPropertiesSet() throws jakarta.resource.ResourceExceptionメッセージエンドポイントを準備し、"autoStartup" フラグが "true" に設定されている場合は自動的にアクティブ化します。- 次で指定:
- インターフェース
InitializingBeanのafterPropertiesSet - 例外:
jakarta.resource.ResourceException
start
stop
stop
インターフェースからコピーされた説明:SmartLifecycleLifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。提供されたコールバックは、
LifecycleProcessorによって使用され、共通のシャットダウン順序値を持つすべてのコンポーネントの順序付けられた、潜在的に同時のシャットダウンをサポートします。コールバック は、SmartLifecycleコンポーネントが実際に停止した後に実行する必要があります。LifecycleProcessorは、stopメソッドのこのバリアントのみを呼び出します。つまり、SmartLifecycle実装では、このメソッドの実装内に明示的に委譲されない限り、Lifecycle.stop()は呼び出されません。デフォルトの実装は
Lifecycle.stop()に委譲し、呼び出しスレッドで指定されたコールバックをすぐにトリガーします。2 つの間に同期がないことに注意してください。カスタム実装では、少なくとも共通のライフサイクルモニター(存在する場合)内に同じ手順を入れたい場合があります。- 次で指定:
- インターフェース
SmartLifecycleのstop - 関連事項:
isRunning
destroy