【问题标题】:Messaging Bridge status using WLST使用 WLST 的消息传递桥状态
【发布时间】:2014-04-02 09:15:56
【问题描述】:

我正在尝试构建一个 WLST 脚本,它告诉我在 AdminServer 上拥有的 n 个消息传递桥的状态。

connect('uname','pswd','t3://localhost:7001');

serverRuntime();

bd= cmo.getMessagingBridgeRuntime();

print bd.getName();

print bd.getState();

我在查找mbean实例时遇到问题,错误如下:

AttributeError: getMessagingBridgeRuntime

如果您已经有这个正在运行的脚本或帮助我解决这个问题,那将会有很大的帮助。

我正在使用 weblogic 10.3.1

【问题讨论】:

  • 在 serverRuntime() 命令之后执行 ls() 并检查是否在 ls 输出中看到“MessagingBridgeRuntime”。
  • 哎呀!它不存在,但为什么它不存在?我需要这段脚本才能工作,还有其他建议吗?
  • 这似乎是因为 Weblogic 9.2 到 10.3.5 中的一个错误。检查您的版本是否有任何相应的补丁或按照wlatricksntips.blogspot.in/2013_04_01_archive.html建议的替代方法

标签: jms wlst


【解决方案1】:

这是查找网桥状态的 JMX java 代码

import javax.management.MBeanServerConnection;
import java.net.MalformedURLException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
import java.util.*;

public class GetMessageBridgeStatus {

private static MBeanServerConnection connection;
private static JMXConnector connector;

public static void  getMessageBridgeStatus(String hostname2,String port2,String username2,String password2,String wlname2, List<String> bridgeName) {

    try
    {
        String hostname=hostname2;
        String port=port2;
        String username=username2;
        String password=password2;
        String wlname=wlname2;

        getRuntimeMBeanServerConnection(hostname,port,username,password);

        Iterator<String> iterator = bridgeName.iterator();
        while(iterator.hasNext()){
            String bName = iterator.next();

            String bs = "com.bea:ServerRuntime="+wlname+",Name="+bName+",Type=MessagingBridgeRuntime,Location=" +wlname;
            ObjectName service = new ObjectName(bs);

            String status = connection.getAttribute(service,"State").toString();

            String description = connection.getAttribute(service,"Description").toString();

            System.out.println("Name: "+bName+" ::: Status: "+status +" ::: Description: "+description);

    }catch(Exception e) {
        e.printStackTrace();
    }

}

public static void getRuntimeMBeanServerConnection(String hostname1,String port1,String username1,String password1)  throws Exception{
    String jndiroot = "/jndi/";
    String mserver = "weblogic.management.mbeanservers.domainruntime";
    String hostname=hostname1;
    String username=username1;
    String password=password1;
    Integer portInteger = Integer.valueOf(port1);
    int port = portInteger.intValue();

    JMXServiceURL serviceURL = new JMXServiceURL("t3", hostname, port,jndiroot + mserver);
    Hashtable h = new Hashtable();
    h.put(Context.SECURITY_PRINCIPAL, username);
    h.put(Context.SECURITY_CREDENTIALS, password);
    h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
    connector = JMXConnectorFactory.connect(serviceURL, h);
    connection = connector.getMBeanServerConnection();
}
}

【讨论】:

    猜你喜欢
    • 2017-12-22
    • 1970-01-01
    • 2015-12-20
    • 2021-04-28
    • 2021-05-09
    • 2014-02-20
    • 2020-11-03
    • 2014-01-18
    • 1970-01-01
    相关资源
    最近更新 更多