クラス GenericMessageEndpointManager

java.lang.ObjectSE
org.springframework.jca.endpoint.GenericMessageEndpointManager
実装されたすべてのインターフェース:
DisposableBeanInitializingBeanLifecyclePhasedSmartLifecycle
既知の直属サブクラス
JmsMessageEndpointManager

public class GenericMessageEndpointManager extends ObjectSE implements SmartLifecycle, InitializingBean, DisposableBean
Spring アプリケーションコンテキスト内の JCA 1.7 メッセージエンドポイントを管理し、アプリケーションコンテキストのライフサイクルの一部としてエンドポイントをアクティブ化および非アクティブ化する汎用 Bean。

このクラスは、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 メッセージブローカーによってサポートされ、Spring Bean として定義されている JMS MessageListenerEE オブジェクト) を示します。

 <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 オブジェクト(どちらもリソースプロバイダーに固有)を指し、場合によっては別のメッセージリスナー(たとえば、以下に基づくリソースアダプターの CCI MessageListenerEE)を指すだけです。JCA Common Client Interface)。

非同期実行戦略は、上記のように ResourceAdapterFactoryBean の "workManager" プロパティを介してカスタマイズできます。ここで、<bean class="..."/> は、JCA 準拠の WorkManager の構成に置き換える必要があります。

トランザクション実行は、指定された MessageEndpointFactory によって構築された、具体的なメッセージエンドポイントの責任です。GenericMessageEndpointFactory は、通常、Spring JtaTransactionManager またはプレーンな TransactionManagerEE 実装がそこで指定されている "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
関連事項:
  • フィールドサマリー

    インターフェース org.springframework.context.SmartLifecycle から継承されたフィールド

    DEFAULT_PHASE
  • コンストラクターのサマリー

    コンストラクター
    コンストラクター
    説明
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    void
    メッセージのエンドポイントを準備し、"autoStartup" フラグが "true" に設定されている場合は、それを自動的にアクティブにします。
    void
    メッセージエンドポイントを非アクティブ化し、シャットダウンの準備をします。
    エンドポイントのアクティブ化に使用する JCA ActivationSpec を返します。
    JCA MessageEndpointFactory を返却してアクティブにします。
    int
    このエンドポイントマネージャーが開始および停止されるフェーズを返します。
    エンドポイントを管理する JCA ResourceAdapter を返します。
    boolean
    'autoStartup' プロパティの値を返します。
    boolean
    設定されたメッセージエンドポイントが現在アクティブかどうかを返します。
    void
    エンドポイントのアクティブ化に使用する JCA ActivationSpec を設定します。
    void
    setAutoStartup(boolean autoStartup)
    このエンドポイントマネージャーが初期化され、コンテキストがリフレッシュされた後に、エンドポイントのアクティブ化を自動で開始するかどうかを設定します。
    void
    エンドポイントが委譲する MessageListener オブジェクトを指すように、JCA MessageEndpointFactory をアクティブに設定します。
    void
    setPhase(int phase)
    この Endpoint Manager を開始および停止するフェーズを指定します。
    void
    エンドポイントを管理する JCA ResourceAdapter を設定します。
    void
    設定されたメッセージエンドポイントをアクティブ化します。
    void
    設定されたメッセージエンドポイントを非アクティブ化します。
    void
    stop(RunnableSE callback)
    Lifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。

    クラス java.lang.ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE
  • コンストラクターの詳細

    • GenericMessageEndpointManager

      public GenericMessageEndpointManager()
  • メソッドの詳細

    • setResourceAdapter

      public void setResourceAdapter(@Nullable ResourceAdapterEE resourceAdapter)
      エンドポイントを管理する JCA ResourceAdapter を設定します。
    • getResourceAdapter

      @Nullable public ResourceAdapterEE getResourceAdapter()
      エンドポイントを管理する JCA ResourceAdapter を返します。
    • setMessageEndpointFactory

      public void setMessageEndpointFactory(@Nullable MessageEndpointFactoryEE messageEndpointFactory)
      エンドポイントが委譲する MessageListener オブジェクトを指すように、JCA MessageEndpointFactory をアクティブに設定します。

      MessageEndpointFactory インスタンスは、異なる ActivationSpec オブジェクトを適用して、複数のエンドポイント(つまり、複数の GenericMessageEndpointManager インスタンス)で共有できます。

      関連事項:
    • getMessageEndpointFactory

      @Nullable public MessageEndpointFactoryEE getMessageEndpointFactory()
      JCA MessageEndpointFactory を返却してアクティブにします。
    • setActivationSpec

      public void setActivationSpec(@Nullable ActivationSpecEE activationSpec)
      エンドポイントのアクティブ化に使用する JCA ActivationSpec を設定します。

      この ActivationSpec インスタンスを複数の ResourceAdapter インスタンス間で共有しないでください。

    • getActivationSpec

      @Nullable public ActivationSpecEE getActivationSpec()
      エンドポイントのアクティブ化に使用する JCA ActivationSpec を返します。
    • setAutoStartup

      public void setAutoStartup(boolean autoStartup)
      このエンドポイントマネージャーが初期化され、コンテキストがリフレッシュされた後に、エンドポイントのアクティブ化を自動で開始するかどうかを設定します。

      デフォルトは "true" です。このフラグをオフにして、明示的な start() 呼び出しまでエンドポイントのアクティブ化を延期します。

    • isAutoStartup

      public boolean isAutoStartup()
      'autoStartup' プロパティの値を返します。"true" の場合、このエンドポイントマネージャーは ContextRefreshedEvent で起動します。
      次で指定:
      インターフェース SmartLifecycleisAutoStartup 
      関連事項:
    • setPhase

      public void setPhase(int phase)
      このエンドポイントマネージャーを開始および停止するフェーズを指定します。起動順序は最低から最高に進み、シャットダウン順序はその逆です。既定では、この値は Integer.MAX_VALUE です。これは、このエンドポイントマネージャーができるだけ遅く開始し、できるだけ早く停止することを意味します。
    • getPhase

      public int getPhase()
      このエンドポイントマネージャーが開始および停止されるフェーズを返します。
      次で指定:
      インターフェース PhasedgetPhase 
      次で指定:
      インターフェース SmartLifecyclegetPhase 
      関連事項:
    • afterPropertiesSet

      public void afterPropertiesSet() throws ResourceExceptionEE
      メッセージのエンドポイントを準備し、"autoStartup" フラグが "true" に設定されている場合は、それを自動的にアクティブにします。
      次で指定:
      インターフェース InitializingBeanafterPropertiesSet 
      例外:
      ResourceExceptionEE
    • start

      public void start()
      設定されたメッセージエンドポイントをアクティブ化します。
      次で指定:
      インターフェース Lifecyclestart 
      関連事項:
    • stop

      public void stop()
      設定されたメッセージエンドポイントを非アクティブ化します。
      次で指定:
      インターフェース Lifecyclestop 
      関連事項:
    • stop

      public void stop(RunnableSE callback)
      インターフェースからコピーされた説明: SmartLifecycle
      Lifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。

      提供されたコールバックは、LifecycleProcessor によって使用され、共通のシャットダウン順序値を持つすべてのコンポーネントの順序付けられた、潜在的に同時のシャットダウンをサポートします。コールバック は、SmartLifecycle コンポーネントが実際に停止した後に実行する必要があります。

      LifecycleProcessor は、stop メソッドのこのバリアントのみを呼び出します。つまり、SmartLifecycle 実装では、このメソッドの実装内に明示的に委譲されない限り、Lifecycle.stop() は呼び出されません。

      デフォルトの実装は Lifecycle.stop() に委譲し、呼び出しスレッドで指定されたコールバックをすぐにトリガーします。2 つの間に同期がないことに注意してください。カスタム実装では、少なくとも共通のライフサイクルモニター(存在する場合)内に同じ手順を入れたい場合があります。

      次で指定:
      インターフェース SmartLifecyclestop 
      関連事項:
    • isRunning

      public boolean isRunning()
      設定されたメッセージエンドポイントが現在アクティブかどうかを返します。
      次で指定:
      インターフェース LifecycleisRunning 
      戻り値:
      コンポーネントが現在実行中かどうか
    • destroy

      public void destroy()
      メッセージエンドポイントを非アクティブ化し、シャットダウンの準備をします。
      次で指定:
      インターフェース DisposableBeandestroy