Getting the Messaging Bridge Runtime Details through Java - Weblogic
The below java jmx code will help us to get the run time details of the messaging bridge in weblogic server.
import java.util.Hashtable;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import javax.naming.Context;
public class GetMessageBridgeStatus {
private static MBeanServerConnection connection;
private static JMXConnector connector;
public static void getMessageBridgeStatus() {
try
{
getRuntimeMBeanServerConnection();
String son = "com.bea:ServerRuntime=AdminServer,Name=Bridge-0,Location=AdminServer,Type=MessagingBridgeRuntime";
ObjectName service = new ObjectName(son);
String status = connection.getAttribute(service,"State").toString();
System.out.println("Status: "+status);
String description = connection.getAttribute(service,"Description").toString();
System.out.println("Descrption: "+description);
}catch(Exception e) {
e.printStackTrace();
}
}
public static void getRuntimeMBeanServerConnection() throws Exception{
String jndiroot = "/jndi/";
String mserver = "weblogic.management.mbeanservers.domainruntime";
JMXServiceURL serviceURL = new JMXServiceURL("t3", "localhost", 8000,jndiroot + mserver);
Hashtable h = new Hashtable();
h.put(Context.SECURITY_PRINCIPAL, "weblogic");
h.put(Context.SECURITY_CREDENTIALS, "welcome1");
h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");
connector = JMXConnectorFactory.connect(serviceURL, h);
connection = connector.getMBeanServerConnection();
}
public static void main(String[] args) {
getMessageBridgeStatus();
}
}
Include the wlfullclient.jar file in the class path(Refer the following post
https://www.albinsblog.com/2012/07/creating-wlfullclientjar-weblogic.html to generate the wlfullclient.jar )