WebLogic Server JMS WLST Script – Who is Connected To My Server
http://blogs.oracle.com/jamesbayer/entry/weblogic_server_jms_wlst_script
日本語化したものはこちら。
http://orablogs-jp.blogspot.com/2011/06/weblogic-server-jms-wlst-script-who-is.html
まずDomain Runtime MBeanのオブジェクト名を初期化します。
private static final ObjectName serviceDomainRuntime;
static {
try {
serviceDomainRuntime =
new ObjectName(
"com.bea:Name=DomainRuntimeService,
Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"
);
} catch (MalformedObjectNameException e) {
throw new AssertionError(e.getMessage());
}
}次に、Domain Runtimeに接続します。public static void initConnection(String hostname, String portString, String username, String password, String mbeanservertype) throws IOException, MalformedURLException {
String protocol = "t3";
Integer portInteger = Integer.valueOf(portString);
int port = portInteger.intValue();
String jndiroot = "/jndi/";
String mserver = "weblogic.management.mbeanservers.domainruntime";
JMXServiceURL serviceURL = new JMXServiceURL(protocol, 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();
}Server Runtimeを取得します。private void getJMSData() throws Exception {
ObjectName[] serverRuntimes = (ObjectName[]) connection.getAttributeserviceDomainRuntime, "ServerRuntimes");
...
各Server Runtimeについて、JMSServer上のJMSRuntimeから最終的にConnectionまでたどり、必要なだけの接続情報を取得します。...
for (ObjectName serverRuntime : serverRuntimes) {
ObjectName jmsRuntime = (ObjectName) connection.getAttribute(serverRuntime,
"JMSRuntime");
ObjectName[] jmsServers = (ObjectName[]) connection.getAttribute(jmsRuntime,
"JMSServers");
ObjectName[] jmsRuntimeConnections = (ObjectName[]) connection.getAttribute(jmsRuntime, "Connections");
...
これらのConnectionオブジェクトには、Jamesのエントリにもあるように接続しているクライアントのホストアドレスを含みます。各Connectionオブジェクトからホストアドレスを取得します。...
for (ObjectName jmsRuntimeConnection : jmsRuntimeConnections) {
String currentHost = (String) connection.getAttribute(jmsRuntimeConnection,
"HostAddress");
...
Session、Consumerオブジェクトへと深掘りしていきます。...
ObjectName[] jmsRuntimeSessions = (ObjectName[]) connection.getAttribute(jmsRuntimeConnection, "Sessions");
for (ObjectName session : jmsRuntimeSessions) {
ObjectName[] jmsConnectionConsumers = (ObjectName[]) connection.getAttribute(session, "Consumers");
for (ObjectName jmsConnectionConsumer : jmsConnectionConsumers) {
String destName = connection.getAttribute(jmsConnectionConsumer, "DestinationName"));
String memberDestName = connection.getAttribute(jmsConnectionConsumer,
"MemberDestinationName"));
...
JMS Server MBeanにあるDestinationsを集計すると、以下のような全てのQueueを表示するいい感じのアプリケーションを作成できるかと思います。この例では、2個のJMSサーバと2個のサーバにまたがっている分散Queueを確認できます。そして、2個のクライアントが両方の分散Queueに接続していることがわかります。原文はこちら。
http://blogs.oracle.com/weblogic_soa_and_more/entry/weblogic_server_jms_mbeans_who
0 件のコメント:
コメントを投稿