Using wsadmin scripting with Java Management Extensions (JMX)

Java™ Management Extensions (JMX) is a framework that provides a standard way of exposing Java resources, for example, application servers, to a system management infrastructure. Using the JMX framework, a provider can implement functions, such as listing the configuration settings, and editing the settings. This framework also includes a notification layer that management applications can use to monitor events such as the startup of an application server.

JMX key features

The key features of the WebSphere® Application Server implementation of JMX include:

  • All processes that run the JMX agent.
  • All runtime administration that is performed through JMX operations.
  • Connectors that are used to connect a JMX agent to a remote JMX-enabled management application. The following connectors are supported:
    • SOAP JMX Connector
    • JMX Remote application programming interface (JSR 160) Remote Method Invocation over the Internet Inter-ORB Protocol (RMI-IIOP) JMX Connector, (the JSR160RMI connector)
    • Remote Method Invocation over the Internet Inter-ORB Protocol (RMI-IIOP) JMX Connector
    • Inter-Process Communications (IPC)
  • Protocol adapters that provide a management view of the JMX agent through a given protocol. Management applications that connect to a protocol adapter are usually specific to a given protocol.
  • The ability to query and update the configuration settings of a runtime object.
  • The ability to load, initialize, change, and monitor application components and resources during run time.

JMX architecture

The JMX architecture is structured into three layers:

  • Instrumentation layer - Dictates how resources can be wrapped within special Java beans, called managed beans (MBeans).
  • Agent layer - Consists of the MBean server and agents, which provide a management infrastructure. The services that are implemented include:
    • Monitoring
    • Event notification
    • Timers
  • Management layer - Defines how external management applications can interact with the underlying layers in terms of protocols, APIs, and so on. This layer uses an implementation of the distributed services specification (JSR-077), which is part of the Java 2 Platform, Enterprise Edition (J2EE) specification.

The layered architecture of JMX is summarized in the following figure:

Figure 1. JMX architecture
Illustrates the architecture of JMX.

JMX distributed administration

The following figure shows how the JMX architecture fits into the overall distributed administration topology of a WebSphere Application Server Network Deployment environment:

Figure 2. Distributed administration of JMX
Illustrates WebSphere Application Server distributed administration of JMX

The key points of this distributed administration architecture include:

  • Internal MBeans that are local to the Java virtual machine (JVM) register with the local MBean server.
  • External MBeans have a local proxy to their MBean server. The proxy registers with the local MBean server.
    Using the MBean proxy the local MBean server can pass the message to an external MBean server that is located on:
    • A node agent that has an MBean proxy for all the servers within its node. The MBean proxies for other nodes are not used.
    • The deployment manager has MBean proxies for all the node agents in the cell.

JMX Mbeans

The product provides a number of MBeans, each of which has different functions and operations available. For example, an application server MBean can expose operations such as start and stop. An application MBean can expose operations such as install and uninstall. Some JMX usage scenarios that you can encounter include:

  • External programs that are written to control the WebSphere Application Server Network Deployment run time and its WebSphere resources by programmatically accessing the JMX API.
  • Third-party applications that include custom JMX MBeans as part of the deployed code, supporting the JMX API management of application components and resources.

The following example illustrates how to obtain the name of a particular MBean:

Using Jacl:

set am [$AdminControl queryNames type=ApplicationManager,process=server1,*]

Using Jython:

am = AdminControl.queryNames('type=ApplicationManager,process=server1,*')

Each WebSphere Application Server runtime MBean can have attributes, operations, and notifications. The complete documentation for each MBean that is supplied with the product is available in this documentation at information_center > Reference > Programming interfaces > Mbean interfaces.

JMX benefits

The use of JMX for management functions in WebSphere Application Server provides the following benefits:

  • Enables the management of Java applications without significant investment.
  • Relies on a core-managed object server that acts as a management agent.
  • Java applications can embed a managed object server and make some of its functionality available as one or several MBeans that are registered with the object server.
  • Provides a scalable management architecture.
  • Every JMX agent service is an independent module that can be plugged into the management agent.
  • The API is extensible, allowing new WebSphere Application Server and custom application features to be easily added and exposed through this management interface.
  • Integrates existing management solutions.
  • Each process is self-sufficient when it comes to the management of its resources. No central point of control exists. In principle, a JMX-enabled management client can be connected to any managed process and interact with the MBeans that are hosted by that process.
  • JMX provides a single, flat, domain-wide approach to system management. Separate processes interact through MBean proxies that support a single management client to seamlessly navigate through a network of managed processes.
  • Defines the interfaces that are necessary for management only.
  • Provides a standard API for exposing application and administrative resources to management tools.