Contenues dans
Trouver plus de documentationRessources d'assistance comprises | Télécharger cet ouvrage au format PDF (1231 Ko)
Chapter 1 Introduction to JMX Programming for Message Queue ClientsWhile Sun Java System Message Queue’s Administration Console and command line administration utilities allow an administrator to interactively configure and monitor Message Queue resources (such as message brokers, connections, and destinations), these tools are not accessible from within a running client application. To provide programmatic access to such administrative functions, Message Queue also incorporates an application programming interface based on the Java Management Extensions (JMX). Client applications can use this API to perform the same configuration and monitoring operations programmatically that are available interactively through the Administration Console and command line utilities. You can use Message Queue’s JMX API in your client applications for a variety of purposes:
In addition, since JMX is the Java standard for building management applications and is widely used for managing J2EE infrastructure, you can use it to incorporate your Message Queue client as part of a larger J2EE deployment using a standard management framework throughout. JMX ArchitectureThe JMX Specification defines an architecture for the instrumentation and programmatic management of distributed resources. This architecture is based on the notion of a managed bean, or MBean: a Java object, similar to a JavaBean, representing a resource to be managed. Message Queue MBeans may be associated with individual resources such as message brokers or destinations, or with whole categories of resources, such as the set of all destinations on a broker. There are separate configuration MBeans and monitor MBeans for setting a resource’s configuration properties and monitoring its runtime state. Each MBean is identified by an object name, an instance of the JMX class ObjectName conforming to the syntax and conventions defined in the JMX Specification. Object names for Message Queue MBeans are either defined as static constants or returned by static methods in the Message Queue utility class MQObjectName; see Object Names for further information. An MBean provides access to its underlying resource through a management interface consisting of the following:
Client applications obtain MBeans through an MBean server, which serves as a container and registry for MBeans. Each Message Queue broker process contains an MBean server, accessed by means of a JMX connector. The JMX connector is used to obtain an MBean server connection, which in turn provides access to individual MBeans on the server. Configuring or monitoring a Message Queue resource with JMX requires the following steps:
See Chapter 2, Using the JMX API for code examples illustrating the technique for various MBean operations. Message Queue MBeansMessage Queue's JMX functionality is exposed through MBeans associated with various Message Queue resources. These MBeans are of two kinds: resource MBeans and manager MBeans. The attributes, operations, and notifications available for each type of MBean are described in detail in Chapter 3, Message Queue MBean Reference. Resource MBeansResource MBeans are associated with individual Message Queue resources of the following types:
Configuration and monitoring functions are implemented by separate MBeans. Each managed resource is associated with a configuration MBean for setting the resource's configuration and a monitor MBean for gathering (typically transient) information about its runtime state. For instance, there is a destination configuration MBean for configuring a destination and a destination monitor MBean for obtaining runtime information about it. In general, each instance of a managed resource has its own pair of MBeans: thus there is a separate destination configuration MBean and destination monitor MBean for each individual destination. (In the case of the Java Virtual Machine, there is only a JVM monitor MBean with no corresponding configuration MBean.) Configuration MBeans are used to perform such tasks as the following:
Monitor MBeans are used to obtain runtime information such as the following:
Manager MBeansIn addition to the resource MBeans associated with individual resources, there are also manager MBeans for managing some whole categories of resources. These manager MBeans also come in pairs—one for configuration and one for monitoring—for the following resource categories:
Unlike individual resource MBeans, a broker has only one pair of manager MBeans for each whole category of resources: for instance, a single destination manager configuration MBean and a single destination manager monitor MBean. For some categories (connection services, connections, destinations), the manager MBeans exist in addition to the ones for individual resources, and are used to manage the collection of resource MBeans within the category or to perform global tasks that are beyond the scope of individual resource MBeans. Thus, for instance, there is a connection manager configuration MBean and a connection manager monitor MBean in addition to the connection configuration and connection monitor MBeans associated with individual connections. Manager MBeans of this type are used to perform tasks such as the following:
In other cases (message producers, message consumers, transactions), there are no MBeans associated with individual resources and all of the resources in the category are managed through the manager MBeans themselves. The manager MBeans for these categories can be used for such tasks as the following:
Object NamesEach individual MBean is designated by an object name belonging to the JMX class ObjectName, which encapsulates a string identifying the MBean. For Message Queue MBeans, the encapsulated name string has the following syntax: com.sun.messaging.jms.server:property=value[,property=value]* Table 1–1 shows the possible properties. Table 1–1 Object Name Properties
Table 1–2 shows the possible values for the object name's type property. Table 1–2 Message Queue MBean Types
Table 1–3 shows the possible values for the object name's subtype property. Table 1–3 Message Queue MBean Subtypes
For destination configuration and destination monitor MBeans, the object name's desttype property specifies whether the destination is a point-to-point queue or a publish/subscribe topic. Table 1–4 shows the possible values, which are defined for convenience as static constants in the utility class DestinationType. Table 1–4 Destination Types
For service configuration and service monitor MBeans, the object name's name property identifies the connection service with which the MBean is associated. Table 1–5 shows the possible values. Table 1–5 Connection Service Names
Table 1–6 shows some example object names. Table 1–6 Example Object Names
The object names for each type of Message Queue MBean are given in the relevant sections of Chapter 3, Message Queue MBean Reference. All such names are either defined as static constants or returned by static methods in the utility class MQObjectName (see Table 1–7). For instance, the constant MQObjectName.BROKER_CONFIG_MBEAN_NAME is defined as a string representing the object name for a broker configuration MBean, and the method call MQObjectName.createDestinationMonitor(DestinationType.TOPIC, "MyQueue"); returns the destination monitor MBean object name shown in Table 1–6. Note that, whereas methods such as createDestinationMonitor return an actual object name (that is, an object of class ObjectName) that can be assigned directly to a variable of that type
ObjectName destMonitorName
= MQObjectName.createDestinationMonitor(DestinationType.TOPIC, "Dest");
constants like BROKER_CONFIG_MBEAN_NAME instead represent an ordinary string (class String) that must then be converted into the corresponding object name itself:
ObjectName brokerConfigName
= new ObjectName(MQObjectName.BROKER_CONFIG_MBEAN_NAME);
Table 1–7 Utility Constants and Methods for
Object Names
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||