如何使用" adminClient.addNotificationListener"在Jython脚本中?

时间:2014-10-06 20:02:32

标签: websphere jython wsadmin

这是文档: http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/tjmx_develop.html

问题是这不起作用:

import javax.management.ObjectName as ObjectName

...
theNodeAgentName = "WebSphere:type=NodeAgent,node='app_node2',*"
test_node_name = adminClient.queryNames(ObjectName(theNodeAgentName), None)
print test_node_name
adminClient.addNotificationListener(ObjectName(theNodeAgentName),listener,None,None)

adminClient实例永远找不到节点代理Mbean。有什么想法吗?

输出:

  

[的WebSphere:名称=节点代理,过程=节点代理,平台=常见的,节点= app_node2,diagnosticProvider =真,版本= 8.5.5.3,类型=节点代理,mbeanIdentifier =节点代理,细胞= my_cell,规格= 1.0]

     

javax.management.InstanceNotFoundException:   javax.management.InstanceNotFoundException:找不到   的WebSphere:类型=节点代理,节点= 'app_node2',*

2 个答案:

答案 0 :(得分:1)

在纯wsadmin中使用JMX通知需要一些Jython黑客攻击。您可以在WDR库中找到一些灵感(解决方案?)(https://github.com/WDR/WDR/)。这里记录了一个使用WDR的工作示例:http://wdr.github.io/WDR/reference/wdr.control.MBean.class.html

答案 1 :(得分:0)

我发现脚本出了什么问题(这是一个pythonistic错误:“adminClient.queryNames”返回一个列表!),我将一个列表传递给“addNotificationListener”函数的第一个参数,诀窍是queryNames并获取列表中的第一个元素,例如:

the_node_agent_name = "WebSphere:type=NodeAgent,node=app_node2,*"
query_name = ObjectName(the_node_agent_name)
node_agent_names = adminClient.queryNames(query_name, None)
node_agent = ObjectName(str(node_agent_names[0]))
print node_agent    
adminClient.addNotificationListener(node_agent,listener,None,None)
相关问题