从weblogic集群获取实例ip

时间:2011-11-21 08:13:49

标签: java cluster-computing weblogic-10.x

我在如何使用weblogic在集群中获取实例URL时遇到问题。

描述: 我们有2个域: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 新泽西 行家

由于

1 个答案:

答案 0 :(得分: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");