メッセージング・エンジンの可用性に依存するアプリケーション

アプリケーションが使用可能なメッセージング・エンジンに依存する場合は、そのメッセージング・エンジンを、アプリケーションを実行する前に開始する必要があります。

アプリケーション・サーバーがアプリケーションを自動的に開始するようにしたい場合は、 必要なメッセージング・エンジンが始動済みであるか検査し、必要であればメッセージング・エンジンが始動するのを待つための アプリケーションを開発する必要があります。この手法を始動 Bean で使用する場合、 アプリケーション・サーバーの始動が遅れないようにするために、始動 Bean メソッドを使用して別のスレッドで作業 (検査および待機) を実行してから、 標準の作業マネージャー・メソッドを使用します。

メッセージング・エンジンの検査および待機のコード例として、 次のコードの抜粋を参照してください。
import java.util.Iterator;
import javax.management.ObjectName;                                     
import com.ibm.websphere.management.AdminService;                       
import com.ibm.websphere.management.AdminServiceFactory;      

    String messagingEngineName = "messagingEngineName"; 
    // Messaging engine to check if started? for example "node01.server1-bus1"
    boolean meStarted = false;                                            
                                                                        
    AdminService adminService = AdminServiceFactory.getAdminService();
    while (!meStarted) {                                                  
      String filterString = "WebSphere:type=SIBMessagingEngine,name=" + 
                             messagingEngineName + ",*";                  
            boolean foundBean = false;                                          
      ObjectName objectName = null;                                       
      try {
        ObjectName objectNameFilter = new ObjectName(filterString);     
        Iterator iter = adminService.queryNames(objectNameFilter,null).iterator();                                                       
        while (iter.hasNext()) {                                        
            objectName = (ObjectName) iter.next();                      
            foundBean = true;                                           
            break;                                                      
        }                                                               
      } catch (Exception e) {
        e.printStackTrace();                                            
      }                                                                   
      if (foundBean) {                                                    
        // You have found messaging engine MBean, which means it is initialized, 
        // now check if it is in Started state?         meStarted = 
          ((Boolean) adminService.invoke(objectName, "isStarted", null, null)).booleanValue();                               
            }                                                                   
                                                                        
      if (!meStarted) {                                                   
        // messaging engine is not started yet so sleep (wait) for a bit...     
        Thread.sleep(5000);                                             
      }                                                                   
    }

トピックのタイプを示すアイコン 概念トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cjb0003_
ファイル名:cjb0003_.html