2011-11-21 156 views
2

我在如何使用weblogic獲取集羣中的實例URL時遇到問題。從weblogic集羣獲取實例ip

說明: 我們有兩個域:X和Y 在每一個領域我有2個集羣:C01和C02 在每個羣集我有實例:S01,S02,S03,S04 在每一個情況下我有我們的包含多個組件的系統,讓我們調用組件A,B,C和D.我想從A到D進行REST調用,它們仍然在同一個實例中。我們將如何以編程方式獲取此REST服務的URL和端口?

問題是,我只是在調用InetAddress或類似項時獲取羣集URL。我也玩過MBean,但我們不確定這是否正確,因爲在創建上下文時,我不會有任何用戶/密碼來填寫Enviroment對象。

我們不希望這作爲構建屬性,因爲我們不想爲每個不同的實例進行構建。

ENV: SpringIntegration 的Weblogic 10.3.3 新澤西 Maven的

感謝

回答

1

解決方案:

得到它從RuntimeServiceMBean:

service = new ObjectName(
       "com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"); 

     InitialContext ctx = new InitialContext(); 
     MBeanServer mBeanServer = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime"); 

     ObjectName rt = (ObjectName) mBeanServer.getAttribute(service, "ServerRuntime"); 
     listenAddress = (String) mBeanServer.getAttribute(rt, "ListenAddress"); 
     server = listenAddress.substring(0, listenAddress.indexOf("/")); 
     port = (Integer)mBeanServer.getAttribute(rt, "ListenPort");   
+1

謝謝,這是有益的。 我有一個問題,但是WLS 12c工作嗎? – clapsus