2011-10-06 13 views
2

設定: 2つのノード#1と#2を持つWLSクラスタ(10.3)。 1つの移行可能なJMSServerは現在#1で利用可能です。 1つの移行可能なJMSQueue。クラスタ環境でJMX経由でJMSQueueにアクセス

問題: 一部のEJBでは、timeToDelieverを60秒に設定してメッセージをJSMQueueに入力しています。 (60秒で表示されません)、別のEJBがJMXを使用して可視(可視ではない)メッセージを取得してから表示されます。この他のEJBが#2で実行されると、JMSServerを見つけることができず、したがってメッセージをポップしません。コードは、非クラスタ環境で正常に動作します:(このコードは、このフォーラムにミクロスCsukaから借りている)



    public class PurgeWLSQueue { 

     private static final String WLS_USERNAME = "weblogic"; 
     private static final String WLS_PASSWORD = "weblogic"; 
     private static final String WLS_HOST = "localhost"; 
     private static final int WLS_PORT = 7001; 
     private static final String JMS_SERVER = "wlsbJMSServer"; 
     private static final String JMS_DESTINATION = "test.q"; 

     private static JMXConnector getMBeanServerConnector(String jndiName) throws Exception { 
      Hashtable h = new Hashtable(); 
      JMXServiceURL serviceURL = new JMXServiceURL("t3", WLS_HOST, WLS_PORT, jndiName); 
      h.put(Context.SECURITY_PRINCIPAL, WLS_USERNAME); 
      h.put(Context.SECURITY_CREDENTIALS, WLS_PASSWORD); 
      h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "weblogic.management.remote"); 
      JMXConnector connector = JMXConnectorFactory.connect(serviceURL, h); 
      return connector; 
     } 

     public static void main(String[] args) { 
      try { 
       JMXConnector connector = 
        getMBeanServerConnector("/jndi/"+RuntimeServiceMBean.MBEANSERVER_JNDI_NAME); 
       MBeanServerConnection mbeanServerConnection = 
        connector.getMBeanServerConnection(); 

       ObjectName service = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"); 
       ObjectName serverRuntime = (ObjectName) mbeanServerConnection.getAttribute(service, "ServerRuntime"); 
       ObjectName jmsRuntime = (ObjectName) mbeanServerConnection.getAttribute(serverRuntime, "JMSRuntime"); 
       ObjectName[] jmsServers = (ObjectName[]) mbeanServerConnection.getAttribute(jmsRuntime, "JMSServers"); 
       for (ObjectName jmsServer: jmsServers) { 
        if (JMS_SERVER.equals(jmsServer.getKeyProperty("Name"))) { 
         ObjectName[] destinations = (ObjectName[]) mbeanServerConnection.getAttribute(jmsServer, "Destinations"); 
         for (ObjectName destination: destinations) { 
          if (destination.getKeyProperty("Name").endsWith("!"+JMS_DESTINATION)) { 
           Object o = mbeanServerConnection.invoke(
            destination, 
            "deleteMessages", 
            new Object[] {""},  // selector expression 
            new String[] {"java.lang.String"}); 
           System.out.println("Result: "+o); 
           break; 
          } 
         } 
         break; 
        } 
       } 
       connector.close(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
    } 

はのJMSServerを指定せずにメッセージ、すなわちI直接できることになっ上の他の方法があります。 JMSQueueに対処するには?他のアイデア?

答えて

0

ああ、解決しました!同じ問題に直面して他人のために
、代わりにドメインのランタイムサービスを使用します。

ObjectName service = new ObjectName("com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"); 

をし、WLS-クラスタ上管理ポートにアクセスしてください。

関連する問題